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>



Output


Picture showing the output of arrow function in JavaScript

Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250