var array = [];
var object = {};
Now, I need an array of empty objects.
array[0] = {};
array[1] = {};
//........
//........
and
var array = [{}];
is obviously not right.
How to define array of (empty) objects in JS?
var array = [{},{},{},{},.........];
Thanks.
EDIT:
The reason I need is the same reason that having an array with undefined length is useful, and mathematically natural in some cases.
I need object wrappers, and for initialization, it's just an empty object, like some values are null or undefined in many cases.
so, I'll have
var object = {};
array[0].value = 'foo', array[1].value = 'bar'.....
However, I do need multiple object wrappers, and the number is not pre-determined, so consequently, I need an arrays of the objects.
So, I am sorry, I modify my Question title
JavaScript How to define an array of undefined length of empty objects?