Tuesday, October 6, 2015

Runtime Javascript anonymous functions

Javascript anonymous functions are function that are dynamically declared at runtime.
In other way function can be created without function name,
Javascript nomal function(with name) will be created using function declaration
But, Anonymous function uses function operator.


Here’s a example of a ordinary function:
  1. function abc()
  2. {
  3.   alert("Created by function declaration");
  4. }
  5. abc();
Here’s the same example created as an anonymous function:
  1. var abc = function()
  2. {
  3.   alert("Created by function operator");
  4. }
  5. abc()
Above code, anonymous function is assigned to a variable abc. Javascript function is also a object like any other object. Hence function objects also can be assigned or passed as parameter.


No comments: