Does Use of Anonymous Functions Affect Performance



The usage of anonymous functions affect performance is the sense, you need to create a new function object at each iteration. Anonymous functions are always loaded using a variable name. Anonymous, as the name suggests, allows creating a function without any names identifier. It can be used as an argument to other functions. Call them using a variable name −

Example

This is how JavaScript anonymous functions can be used −

var func = function() {
   alert(‘This is anonymous');
}
func();

Here’s an example −

//anonymous function
var a = function() {
   return 5;
}
Updated on: 2020-06-23T12:58:03+05:30

295 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements