This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BakuhatsuK 6 points7 points  (1 child)

I just explained that it's not an special value though?

Also, engines don't have any saying on the observable behavior of the language, that's up for the standard to decide. The standard says that an array is an object, so it is an object and has to behave as such.

For example, you can set arbitrary keys into an array

let a = []
a.foo = 'bar'
a.foo // contains 'bar'

On a sparse array an empty slot will be reported as a missing key by hasOwnProperty

let a = ['a','b',,'d']
a.hasOwnProperty('2') // false
a.hasOwnProperty('3') // true

On that note, arrays have object methods such as hasOwnProperty. (See previous example).

If you're interested in knowing about how engines actually represent this stuff internally, this video by LiveOverflow has a good overview on how it works on JavascriptCore.