What is an anonymous function in JavaScript?

JavascriptFront End TechnologyObject Oriented Programming

A function expression is similar to and has the same syntax as a function declaration One can define "named" function expressions (where the name of the expression might be used in the call stack for example) or "anonymous" function expressions.

An example of an anonymous function expression (the name is not used) −

var myFunction = function() {
   // Function code

This function can be invoked using the variable name referring to it −


In conclusion, an anonymous function is a function that is not stored but is associated with a variable. Anonymous functions can accept inputs and return outputs, just as standard functions

Published on 27-Nov-2019 09:54:42