第1道
var a = {'num':1};
var b = a;
a.num +=1;
b.num +=1;
console.log(a.num) //3
console.log(b.num) //3
第2道
for(var i=0;i<10;i++){
setTimeout(function(){
console.log(i);
},1000);
}
image.png
var a = {'num':1};
var b = a;
a.num +=1;
b.num +=1;
console.log(a.num) //3
console.log(b.num) //3
for(var i=0;i<10;i++){
setTimeout(function(){
console.log(i);
},1000);
}
image.png
本文标题:js面试题
本文链接:https://www.haomeiwen.com/subject/doesirtx.html
网友评论