Are Javascript arrays primitives? Strings? Objects? -


are arrays merely objects in disguise? why/why not? in way(s) (such/not)?

i have thought of arrays , objects in js same, because accessing them identical.

var obj = {'i': 'me'}; var arr = new array(); arr['you'] = 'them';  console.log(obj.i); console.log(arr.you); console.log(obj['i']); console.log(arr['you']); 

am mislead/mistaken/wrong? need know js literals, primitives, , strings/objects/arrays/etc...?

are arrays/objects merely strings in disguise? why/why not? in way(s) (such/not)?

arrays objects.

however, unlike regular objects, arrays have special features.

  1. arrays have additional object in prototype chain - namely array.prototype. object contains so-called array methods can called on array instances. (list of methods here: http://es5.github.com/#x15.4.4)

  2. arrays have length property (which live, ergo, auto-updates) (read here: http://es5.github.com/#x15.4.5.2)

  3. arrays have special algorithm regarding defining new properties (read here: http://es5.github.com/#x15.4.5.1). if set new property array , property's name sting can coerced integer number (like '1', '2', '3', etc.) special algorithm applies (it defined on p. 123 in spec)

other these 3 things, arrays regular objects.

read arrays in spec: http://es5.github.com/#x15.4


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -