Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Array is not a data type in Javascript?

According to Professional Javascript for Web developers array is not a datatype in Javascript:

❑   “undefined” if the value is undefined 
❑   “boolean” if the value is a Boolean 
❑   “string” if the value is a string 
❑   “number” if the value is a number
❑   “object” if the value is an object or null 
❑   “function” if the value is a function

Is that correct?

like image 543
ajsie Avatar asked Oct 16 '25 00:10

ajsie


2 Answers

This is correct, Array is just a descendant of object. Note though it does override a few things, for example .toString() in an array prints it's members in a comma list, instead of "[Object object]" like a plain object would.

like image 139
Nick Craver Avatar answered Oct 18 '25 15:10

Nick Craver


I believe that is because an "Array" is an "object"

http://jsfiddle.net/z5Gv2/

like image 29
Jason Avatar answered Oct 18 '25 15:10

Jason