One question I have is why it's not recommended to declare an array like this:
var arr = new Array()
I always thought that declaring with []
was safer in case of accidentally overwriting the Array
object, but...
Array = 1;
var arr = [] // boom
TypeError: Cannot read property 'slice' of undefined
Personally, I tend to use var arr = []
, especially after encountering such issues. Now I'm curious about what exactly makes using []
better than Array
other than potential speed advantages.