Array.push()仅对对象的特定索引有效吗?

I'm setting up an object with year objects, month arrays, and days that are arrays of post objects. When I try to push data to postData[year][month][date], it pushes to all the date arrays in month.

let postData = {}

const addPosts = (year, month, newPosts) => {
  postData[year] = postData[year] || {}
  postData[year][month] = postData[year][month] || Array(30).fill([])
  postData[year][month][0].push('post')

  return postData
}

输出:

{
  "2020": {
    "4": [
      [
        "post"
      ],
      [
        "post"
      ],
      [
        "post"
      ],
      ...
    ]
  }
}

我不了解.push()是否存在某些问题,或者.push()可以进入的索引数量是否受到限制?

评论