Predict Spread 运算符
预测输出 简单
题目
什么做 这个 code print?
代码
const a = [1, 2];
const b = [3, 4];
const combined = [...a, ...b];
console.log(combined);
提示
Spread expands 数组元素到 新数组.
解释
spread 运算符 ... expands 数组's 元素到 enclosing 数组 literal. [..., ...b] 是 equivalent 到 [1, 2, 3, 4]. 这个创建新 数组 — originals ` and b` 是不 修改.
相关资源
相关课程
- JavaScript 数组
学习关于 spread 运算符.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。