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.

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...