var id = 11;
function fn2(){
this.id = 1;
setTimeout(function(){
console.log(this.id);
console.log(this.id2)
}, 150);
setTimeout(() => {
console.log(this.id);
console.log(this.id2);
}, 200)
}
fn2.call({id2: 33});
function Timer() {
this.s1 = 0;
this.s2 = 0;
// 箭头函数
setInterval(() => this.s1++, 1000);
// 普通函数
setInterval(function () {
this.s2++;
}, 1000);
}
var timer = new Timer();
setTimeout(() => console.log('s1: ', timer.s1), 3100);
setTimeout(() => console.log('s2: ', timer.s2), 3100);
console