Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Memory shouldn't make a difference.
a = Array(1e7); for ( let i=0; i<1e7; i++ ) a[i] = i;
takes ~50
ms on my machine.Array.from(..)
takes ( wait for it - literally :P ) ~3300
ms.For
1e3
elements, it's ~.2
ms vs. ~1
ms.How is this performance-/memory-wise compared to populating it via a
for
loop?Thank you, that was helpful!
The object doesn't even contain undefined items. It only has
length
. There's a difference between existing properties that happen to beundefined
and actual missing, or empty, ones. Cf.[undefined,0]
vs.[,0]
( yes, that's valid JS ). But if you ask for a non-existent property, JS will not throw aReferenceError
, but give youundefined
instead, unlike when you ask for a non-existent variable.Someone tell me if I'm wrong please: the object the array is being mapped from contains N undefined objects, so the indexes of N undefined objects are mapped to the array.
JohaWiltink, thx.
Thanks about convention of not used variables!