数组引用概念
概念检查 中等
题目
什么 happens 当你 assign 数组到 新变量 and 推送到 它?
提示
数组是 引用类型 in JavaScript.
解释
Arrays are objects in JavaScript, and objects are reference types. When you do const b = a;, both a and b point to the same array in memory. Pushing to b also affects a because they are the same array. To create an independent copy, use [...a] (spread) or a.slice().
相关资源
相关课程
- JavaScript 数组
学习关于引用对比值 类型.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。