1. What is it?
It has Function Expression
//anonymous function expressionvar a = function() { return 3;}a(); //self invoking function expression(function sayHello() { alert("hello!");})(); and Function Declaration
function bar() { return 3;} 2. JavaScript Closures// Inner classJavaScript variables can belong to the local or global scope.Private variables can be made possible with closures.
function add() {
var counter = 0;
function plus() {counter += 1;}
plus();
return counter;
}
REF
W3C
IF HEMINGWAY WROTE JAVASCrIPT
沒有留言:
張貼留言