首页 > 解决方案 > 数组推送中的扩展或剩余运算符

问题描述

我想了解为什么 ...list - spread syntax - (我相信它是传播的,因为它处理可迭代)以这种方式添加到列表中。这是否意味着将列表收集在一个数组中并推送到 tempLists 中?

              const tempLists = [];

              // eslint-disable-next-line no-restricted-syntax
              for (const list of response.data.lists) {
                tempLists.push({ ...list, items: [] });
              }

标签: javascriptspread-syntax

解决方案


推荐阅读