|
|
All functions in JavaScript are objects, so a function reference is actually an object reference. Take a look at the following example:
As you can see, a function reference can be handed to a variable. The function can then be executed by invoking that variable via a set of parentheses. This technique can be very convenient for easy-to-follow cross-browser scripts. Here's a demonstration:
In some situations, only function references are accepted. For example, a constructor function that creates a custom object must assign a function reference to its method specifications:
Event handlers specified as properties also require function references:
|
Send mail to santhosh_emids@yahoo.com with questions or comments about
this web site.
|