发布于 2018-11-19 16:46:06
你不能推翻康斯特,另一个意思是你不能重新分配康斯特。
const a = 1;
a = 2; // you will get TypeError. *** numbers and strings are also immutable但是,您可以修改常量而不重新分配类型。
const b = {};
b.a = 'new property'; // { a: "new property" }
const c = [];
c[0] = "new stack"; // ["new stack"]您可以修改,但不能重新分配const。
https://stackoverflow.com/questions/53378900
复制相似问题