I was reading about understanding arrays in another link, but still stuck..
JavaScript Storing Data in 2-D Array
Javascript Appending to 2-D Array
understanding nested arrays in Javascript
The problem is, i have sample code that i want to learn, but when i did in different style(cz different situation), i got stuck. The sample problem is like : (uses f12 in browser to check console)
It looks different, but when i check inside it's the same..
Both arrays are created in different ways, the first one is (i want to make this) :
var datas = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
And the other array (my own method) :
mydatas=[];
and how i add this elements to this array is:
mydatas.push(newArr);
And my half code to compare it : (many other thing to do, but didnt connect to this problem)
var datas = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
var mydatas=[];
for(i=0;i<Oldarry.length;i++){
//other proccess
newArr = [address, latlng.lat(), latlng.lng(), (index+1)];
mydatas.push(newArr);
}
console.log(datas);
console.log(datas[0]);
console.log(mydatas);
console.log(mydatas[0]);
The result is :
My question is how I could create the first array (datas). Thanks for any help.
*The strange in mydatas i can't access first array, but in second picture if i click in console there are 7 array inside..
my full code without api key: https://jsfiddle.net/n425qxgy/