Working with hooks (Closure)

Run Settings
LanguageJavaScript
Language Version
Run Command
function hook(param = null) { let data = param; let value = function(){ return data; }; let setValue = function(val){ data = val; }; // const newObj = new createDefaultObject(5); // const a = 5; // const a1 = x => console.log(x); // const arr = []; // arr.push(a); // arr.push(a1); // console.log(newObj.setValue(5)); return [value, setValue]; } let [value, setValue] = hook('initial'); console.log(value()); setValue('working'); console.log(value()); setValue('not working'); console.log(value());
Editor Settings
Theme
Key bindings
Full width
Lines