当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Error in sequential execution of pop command and push command?

问题描述:

I used the push command and printed the array before using the pop command, but it is not applied and is gone

var a={

arr:[],

boolean:true,

test:function(){

if(a.boolean){

a.arr.push(1);

console.log(a.arr);

}

if(a.boolean)

a.arr.pop();

}

}

Image

网友答案:

That's because the content of your array is evaluated only after you click the arrow to the left of the array in your console. So what you see in the console in both cases is the result after both push and pop, so they appear empty.

If you hover over the little i symbol to the right of Array[1], it tells you exactly that ("Value below was evaluated just now").

分享给朋友:
您可能感兴趣的文章:
随机阅读: