Function Object Constructor

var myClass = function (doodad) { this.doodad = doodad;

return this;

Function = Closure function myFunction() { var counter = 0;

function closureFunction() { counter++; alert(counter);

closureFunction(); // shows '1' closureFunction(); // shows '2'

Function = Closure function myFunction() { var counter = 0;

function closureFunction() { counter++; alert(counter);

return closureFunction;

var closure = myFunction(); closure(); // shows '1' closure(); // shows '2'

0 0

Post a comment