6

Can anyone tell me what the fuck is going on here?

Comments
  • 1
    Empty 2D Array with 1D having five allocations?
  • 6
    The "title" of the log message might've been evaluated before the elements were removed from the array. Then when you expand the log the items of the array have already been removed, but the "title" of the log message hasn't been updated. That's my guess on it.
  • 1
    @ItsaMeTuni Mine too.
  • 2
    @ItsaMeTuni is spot on. It happens all the time. If you want an exact output of an array at an exact point in time, you can log it as a string.
  • 8
    something like this perhaps?
  • 3
    Read the god damn information bubble!!!!!!
    Gotta teach this like every fucking junior
  • 0
    Skrr. Skrr.
  • 1
    Arrays in JavaScript don't exist, they're just plain object which have the length property, number as keys and the Array prototype.

    You can create arrays also like this:

    function HomeMadeArray() {
    this[0] = 'abc';
    this[1] = 'def';
    this.length = 2;
    }

    HomeMadeArray.prototype = Array.prototype;

    new HomeMadeArray(); // ['abc', 'def']
  • 0
    It's just that the length property is independent of the number of elements but items being added to the array handles the increment/decrement
Add Comment