javascript - 数组推送中的扩展或剩余运算符
问题描述
我想了解为什么 ...list - spread syntax - (我相信它是传播的,因为它处理可迭代)以这种方式添加到列表中。这是否意味着将列表收集在一个数组中并推送到 tempLists 中?
const tempLists = [];
// eslint-disable-next-line no-restricted-syntax
for (const list of response.data.lists) {
tempLists.push({ ...list, items: [] });
}
解决方案
推荐阅读
- javascript - javascript 使用下拉框添加动态列表
- mysql - MySQL 无法使用 SELECT IN 检索重复的行
- reactjs - 在 svg 中嵌入 svg 的样式(在 Chrome 上)
- php - Laravel 7:尝试获取名称而不是 id
- angular - Angular 10.1 Ivy 不理解 *ngFor 指令
- next.js - create-next-app 不起作用,出现内部服务器错误
- postgresql - 通过 VPC 连接器连接 Google Cloud Platform 的计算引擎和应用引擎
- python - 使用 pybind11 将向量从 C++ 传递到 Python
- java - 无法识别 startActivityForResult 中的 int?
- arrays - 两个指针问题和滑动窗口一样吗