我有以下要执行的代码段,
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
为什么输出此代码是:
0
未定义