android-logo

Anonymous Function in JavaScript


An anonymous function is one that has no name. Anonymous functions can be sent as a parameter to other functions.


Example


let display = function() {
    console.log('This is anonymous function');
};

display();
}  

Output

This is anonymous function


The anonymous function in the preceding example has no name between the function keyword and the parentheses.

Anonymous functions as arguments


setTimeout(function() {
    alert('anonymous function');
  }, 1000);


facebook-logo
twitter-logo
instagram-logo

2020 © All rights reserved.