这个程序怎么改 让handle[1]弹1,handle[2]弹2;
var handle=[];
function bindEvent() {
for(var i=0;i<=2;i++){
handle[i]=function () {
alert(i);
}
}
}
bindEvent();
handle[1]();
handle[2]();
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
闭包。
使用闭包:
或者 用let代替var