Are Javascript arrays primitives? Strings? Objects?
Arrays are objects.
However, unlike regular objects, arrays have certain special features.
Arrays have an additional object in their prototype chain - namely
Array.prototype
. This object contains so-called Array methods which can be called on array instances. (List of methods is here: http://es5.github.com/#x15.4.4)Arrays have a
length
property (which is live, ergo, it auto-updates) (Read here: http://es5.github.com/#x15.4.5.2)Arrays have a special algorithm regarding defining new properties (Read here: http://es5.github.com/#x15.4.5.1). If you set a new property to an array and that property's name is a sting which can be coerced to an integer number (like
'1'
,'2'
,'3'
, etc.) then the special algorithm applies (it is defined on p. 123 in the spec)
Other than these 3 things, arrays are just like regular objects.
Read about arrays in the spec: http://es5.github.com/#x15.4
Are arrays objects in JavaScript?
Arrays are indeed a type of object.
console.log([] instanceof Object);
Related Topics
Finding All Combinations (Cartesian Product) of JavaScript Array Values
Jquery Xml Error ' No 'Access-Control-Allow-Origin' Header Is Present on the Requested Resource.'
What Does "Options = Options || {}" Mean in JavaScript
When You Pass 'This' as an Argument
Is Safari on iOS 6 Caching $.Ajax Results
Read Environment Variables in Node.Js
In JavaScript, Why Is "0" Equal to False, But When Tested by 'If' It Is Not False by Itself
How to Resize Images Proportionally/Keeping the Aspect Ratio
Add Directives from Directive in Angularjs
How to Get the File Name from a Full Path Using JavaScript
How to Focus on a <Div> Using JavaScript Focus() Function
Is ".Then(Function(A){ Return A; })" a No-Op for Promises
Assigning Prototype Methods *Inside* the Constructor Function - Why Not
Can (A== 1 && a ==2 && A==3) Ever Evaluate to True
How to Check a Not-Defined Variable in JavaScript