admin管理员组文章数量:1291283
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?
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?
Share Improve this question edited Nov 10, 2010 at 19:30 BoltClock 724k165 gold badges1.4k silver badges1.4k bronze badges asked Nov 10, 2010 at 19:27 ajsieajsie 79.8k110 gold badges284 silver badges386 bronze badges5 Answers
Reset to default 5This 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 ma list, instead of "[Object object]"
like a plain object would.
I believe that is because an "Array" is an "object"
http://jsfiddle/z5Gv2/
As others say it's treated as "object". You can test for an object being an array by checking if its constructor is === to Array.
yes , Array is not a data type in JavaScript. The set of types in JavaScript are of Primitive values and Objects.
So Array falls under the category of Objects.
Arrays are not a data type in Javascript because under the hood they are objects with key:value pairs. Where the keys are the index and values are the array content. For example
let example = ["a","b","c","d","e"]
is the same as an object representation
let example = {
0: "a",
1: "b",
2: "c",
3: "d",
4: "e"
};
本文标签: Array is not a data type in JavascriptStack Overflow
版权声明:本文标题:Array is not a data type in Javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741529020a2383641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论