var arr = []; arr.length → "0" arr[3] → "undefined" // No array bounds exception??? arr[3] = "hi"; arr.length → "4" // 4??? Only one element has been added! arr["3"] → "hi" // Apparently "3" is coerced into a number
The Top 10 Things Wrong with JavaScript
Richard Kenneth Eng
11123

Having no out of bounds exception is very common, especially in scripting languages.

I’d expect arr[3] = “hi” to then produce an array of length 4.

The array would look like this [undefined, undefined, undefined, “hi”].

“3” isn’t coerced into a number, it’s the key. Do Object.keys(arr) on that array. It’d produce [“3”]

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.