DEV Community

Discussion on: When is an array, not an array?

Collapse
 
thejoezack profile image
Joe Zack Coding Blocks

Hey thanks!

Also, did you know that you can set the length property?

Check this out:

var x = [1,2,3,4,5];
x.length = 2;
// end up with [1,2]
Collapse
 
antogarand profile image
Antony Garand

Yea, that's a nice way to trim the end of an array!

Interesting but weird behavior, it suits JS