答案 0 :(得分:0)
@CertainPerformance是正确的。如果要具有对象,则必须具有关联的属性。
var a = [ { propertyName : [] } ]
然后您可以像这样访问该数组:
a[0].propertyName
或a[0]['propertyName']
您也可以在对象内部包含多个值:
var a = [
{
propertyName_1 : [],
propertyName_2 : "",
propertyName_3 : 3,
}
];
答案 1 :(得分:0)
var a = [{}] // no problem, you are assigning an empty object `{}` as first element of array
var a = [[]] // no problem, you are assigning an empty array `[]` as first element of array
var a = [{[]}] // Not working because you're assigning empty array into object
//object needs key to store value
var a = {[]} //Not ok <<======== have you ever see var a = { 1, 2, 3} ?
请参阅documentation:
对象是属性的集合,属性是名称(或键)与值之间的关联。