Closures

Run Settings
LanguageJavaScript
Language Version
Run Command
/* Closure functions are functions that refer to the state of their enclosing function's scope (this includes the 'this' keyword). Any free variable in the closure function that is declared in the outer function's scope or received as a parameter. */ function parent(param) { return function () { console.log(param); }; } var a = parent('here'); a(); /* This behavior can also be chained. */ function parent_2(param) { function getter() { return function () { console.log(param); }; } return getter; } var b = parent_2(2); var c = b(); c();
Editor Settings
Theme
Key bindings
Full width
Lines