标签: javascript scope
/ *为什么此代码输出3 3 3,而是应打印0 1 2 * /
var printVal = []; for(var i = 0;i<3;i++){ printVal.push(()=> console.log(i)); } printVal.forEach((f) => f());