Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Работа с двумерным массивом (https://javascript.ru/forum/misc/57866-rabota-s-dvumernym-massivom.html)

dllec 24.08.2015 12:25

Работа с двумерным массивом
 
Добрый день!

var earth = [[],[]];


earth = [0].push(3);
earth = [0].push(5);
earth = [0].push(7);
earth = [0].push(9);


earth = [1].push(13);
earth = [1].push(15);
earth = [1].push(17);
earth = [1].push(19);
earth = [1].push(21);


console.log(earth[0].length);
console.log(earth[1].length);
console.log(earth[1][0]);


Что не так, не правильно объявляю?

tsigel 24.08.2015 12:35

var earth = [[], []];

earth[0].push(3);
earth[0].push(5);
earth[0].push(7);
earth[0].push(9);

earth[1].push(13);
earth[1].push(15);
earth[1].push(17);
earth[1].push(19);
earth[1].push(21);

console.log(earth[0].length);
console.log(earth[1].length);
console.log(earth[1][0]);

dllec 24.08.2015 12:42

ай, блин. Надо же такую глупость допустить. Спасибо


Часовой пояс GMT +3, время: 15:20.