为什么是这样的输出呢?
//情形1
function print(){
this.i = 0;
return function(){
console.log(i++);
}
}
var a1 = print();
var a2 = print();
a1(); //0
a1(); //1
a2(); //2
var a3 = new print();
a3(); //3
a3(); //4
//情形2
function print(){
var i = 0;
return function(){
console.log(i++);
}
}
var a1 = print();
var a2 = print();
a1(); //0
a1(); //1
a2(); //0
var a3 = new print();
a3(); //0
a3(); //1