问题描述:

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").

相关阅读:
Top