Articles → JavaScript → Anonymous function in JavaScript

Anonymous function in JavaScript






Purpose





Example


<html>

<head>
	<title>Anonymous function demo</title>
	<script>
	//  Assigning function to a variable
	var anony = function(a, b) {
		alert(a + b);
	};
	// Calling variable as function    
	anony(4, 3);
	</script>
</head>

<body> </body>

</html>



Output


Picture showing the output of anonymous function in javascript

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, May 27, 2020

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250