How to construct Array of Objects

0

I'm trying to build an Array of Objects in JavaScript, but the result is not as expected. This is how I would like it to be:

Butthat'showit'sstaying:

This is the code I'm using:

var wo = new Array();
while ( listItemEnumerator.moveNext() ) 
        {
            var oListItem = listItemEnumerator.get_current();
            wo.push( { ID: oListItem.get_id(), Status: oListItem.get_item( 'Status' ) } );
        }

I need Object Array to be built within WHILE
Can someone help me?

    
asked by anonymous 30.07.2014 / 13:57

1 answer

1

There is no difference between the two, the difference is in how the Chrome console is showing it only.

And it is not by the size of the Array that it does this, by the tests I've done here it changes the way it displays the array if at the time the console.log is called the development tools are open.

Testing here in version 36 of Chrome, if I have the development tools open and then open the page with Script the result is the second, but if I leave the development tools closed, I open the page and only after it runs the script I open the development tools then the result will be the first one.

And just a note, recommended at the time of creating an array in javascript is to use as follows

var wo = [];

You can read a bit more about that on the w3schools site in the "Avoid new Array ( ) "

    
30.07.2014 / 15:09