当您使用constJavaScript制作内容时,您无法将变量本身重新分配为引用其他内容。但是,该变量仍可以引用可变对象。const x = {a: 123};// This is not allowed. This would reassign `x` itself to refer to a// different object.x = {b: 456};// This, however, is allowed. This would mutate the object `x` refers to,// but `x` itself hasn't been reassigned to refer to something else.x.a = 456;就字符串和数字之类的基元而言,const它更易于理解,因为您无需对值进行突变,而是为变量分配了一个新值。