I have following code snippet to be executed,
function OuterFn(){
var slices = 0; // variable inside Outer function
this.getSlices = function(){
return slices;
}
this.slice = function(){
slices++;
}
}
var outerFn = new OuterFn();
console.log(outerFn.getSlices());
console.log(outerFn.slices); // print outer function variable
Why output of this code is:
0
undefined
new OuterFn()). For more about this, see [github.com/getify/You-Dont-Know-JS/tree/master/…