I need to create an array initialized to the length of an object. Then be able to insert new data into an index within the array.
Code example:
$scope.holder = new Array($scope.x.length);
$scope.holder[0].new_data = response.data;
However the above will give error:
TypeError: Cannot set 'new_data' of undefined
How can this be if I specified the size of the array? Is the array not meant to have three objects in it. How can I solve this problem?
$scope.holder[0]is not defined yet, array has three undefined items