我有一个阵列含有一个动态的数量的部分,每一部分含有一个动态的数量的项目。
因此,它是一个数组,但如何声明吗? 下面的代码不能工作:
const sections = []
sections[0].push(sectionItem)
sections[0].push(sectionItem)
sections[1].push(sectionItem)
sections[1].push(sectionItem)
sections[1].push(sectionItem)
sections[2].push(sectionItem) // 'sectionItem' is different each time of course
什么是正确的方式完成这个吗?