for (var i=0 i<items.length i++) {
var item = items[i]
setTimeout(function(){
item.style.backgroundColor = 'red'
},5)
}
function f(i, arr) {console.log(arr[i])
}
function createB() {
var arr = [{x: 100, y: 200}, {x: 300, y: 400}, {x: 500, y: 600}, {x: 700, y: 800}]
for (var i = 0 i < arr.length i++) {
setTimeout(f, 1000 * i, i, arr)
}
}
createB()
function FangFa(){ ...... } function Start(){ setInterval(FangFa, 3000)//每3秒调用一次方法 } setTimeout(Start, 5000)//延迟5秒开始周期回调