I am trying to get a list of all the elements that are in the JavaScript array, but I noticed that using array.toStringdoes not always display the entire contents of the array, even if some elements of the array have been initialized. Is there a way to print each element of an array in JavaScript along with the corresponding coordinates for each element? I want to find a way to print a list of all the coordinates that were defined in the array, along with the corresponding values for each coordinate.
http://jsfiddle.net/GwgDN/3/
var coordinates = [];
coordinates[[0, 0, 3, 5]] = "Hello World";
coordinates[[0, 0, 3]] = "Hello World1";
console.log(coordinates[[0, 0, 3]]);
console.log(coordinates[[0, 0, 3, 5]]);
console.log(coordinates.toString());
source
share