JavaScript对象文字和数组文字

前端之家收集整理的这篇文章主要介绍了JavaScript对象文字和数组文字前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对象文字JavaScript中的数组文字有什么区别?我知道它与长度方法有关,但我不完全明白.

解决方法

Mozilla.org对不同文字的例子有非常好的解释.

Array Literals

An array literal is a list of zero or
more expressions,each of which
represents an array element,enclosed
in square brackets ([]). When you
create an array using an array
literal,it is initialized with the
specified values as its elements,and
its length is set to the number of
arguments specified.

Object Literals

An object literal is a list of zero or more pairs of property names and associated values of an object,enclosed in curly braces ({}). You should not use an object literal at the beginning of a statement. This will lead to an error or not behave as you expect,because the { will be interpreted as the beginning of a block.

原文链接:https://www.f2er.com/js/151161.html

猜你在找的JavaScript相关文章