Introduction to Objects & Arrays in JavaScript

preview_player
Показать описание
A very simple overview of Objects and Arrays as well as some 'gotchas'.
Рекомендации по теме
Комментарии
Автор

if i have an array of objects and wanted to remove one of the objects from the array and add it to another array, how would I do that, it seems all the array methods return an array with the object as it's single element when i just want the object...

TheWarriorScholar
Автор

Thanks for this. I was wondering if it would be possible to subtitle the questions onto the video?

psychospydr
Автор

If you try this test, it shows that for(var i = 0...) is much(100-150 times) faster even with 1000 elements

var arr = [];
for (var i = 0; i < 1000; i++) arr[i] = 0;

function walkIn(arr) {
for (var key in arr) arr[key]++;
}

function walkLength(arr) {
for (var i = 0; i < arr.length; i++) arr[i]++;
}

function bench(f) {
var date = new Date();
for (var i = 0; i < 10000; i++) f(arr);
return new Date() - date;
}

alert( 'TIme walkIn: ' + bench(walkIn) + 'ms' );
alert( 'Time walkLength: ' + bench(walkLength) + 'ms' );

Vesell