0

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

Zoe
  • 27,060
  • 21
  • 118
  • 148
  • 1
    Possible duplicate of [Is Chrome's JavaScript console lazy about evaluating arrays?](http://stackoverflow.com/questions/4057440/is-chromes-javascript-console-lazy-about-evaluating-arrays) – cartant Jan 19 '17 at 04:06

1 Answers1

0

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

Assan
  • 428
  • 1
  • 4
  • 10