查找: Missing Readonly
找错误 中等
题目
这个 code 有类型错误. 查找 mistake:
代码
const arr: readonly number[] = [1, 2, 3];
arr.push(4);
提示
Readonly 数组 cannot 是 mutated. 什么方法是 是 called?
解释
The array is declared as readonly number[], which means it cannot be mutated. The push method is not available on readonly arrays. TypeScript errors: Property 'push' does not exist. Fix: create a new array instead: const newArr = [...arr, 4]; or remove the readonly modifier if mutation is intended.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。