如何声明一个可以包含无限量值的JavaScript对象,如下所示?我是Javascript的新手。
var activities = [
{
subject: "",
genre :"",
username: "",
aboutuser: ""
},
{
subject: "",
genre :"",
username: "",
aboutuser: ""
},
{
subject: "",
genre :"",
username: "",
aboutuser: ""
},
...
]
答案 0 :(得分:2)
像这样:
let myArray = []
myArray.push({
subject: "",
genre :"",
username: "",
aboutuser: ""
})
只需定义一个空数组,并将对象多次推入其中。