Articles → JAVASCRIPT → Arrow Function In Javascript

Arrow Function In Javascript






Purpose





Example


<html>
  <head>
    <title></title>
    <script>
      /*Traditional way of writing function*/
      myMessageOne = function ShowMessageOne(message) {
        alert(message);
      }
      /*Arrow function with no parameters*/
      myMessageTwo = () => {
        alert("Arrow function demo");
      }
      /*Arrow function with parameters*/
      myMessageThree = (message) => {
        alert(message);
      }
      myMessageOne("Hi");
      myMessageTwo();
      myMessageThree("Arrow function demo 2");
    </script>
  </head>
  <body></body>
</html>

Try It


Output


Picture showing the output of arrow function in JavaScript


Picture showing the output of arrow function in JavaScript


Picture showing the output of arrow function in JavaScript



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, April 28, 2020

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250