Anonymous Functions
You can create anonymous functions, which are functions created using the function()
{ ... } syntax. They are not given names, but they can be assigned to variables. Here is an
Example of an anonymous function:
6 CHAPTER 1 ¡ EXPRESSIVE JAVASCRIPT
/* An anonymous function, executed immediately. */
(function() {
var foo = 10;
var bar = 2;
alert(foo * bar);
})();
{ ... } syntax. They are not given names, but they can be assigned to variables. Here is an
Example of an anonymous function:
6 CHAPTER 1 ¡ EXPRESSIVE JAVASCRIPT
/* An anonymous function, executed immediately. */
(function() {
var foo = 10;
var bar = 2;
alert(foo * bar);
})();
Comments
Post a Comment