其他分享
首页 > 其他分享> > const 对象的属性能否修改

const 对象的属性能否修改

作者:互联网

const保证的并不是变量的值不能改动,而是变量指向的那个内存地址不能改动。
const aa=true
aa=false
console.log(aa)
// VM1089:2 Uncaught TypeError: Assignment to constant variable.
const aaa=3
aaa=5
console.log(aaa)
// VM1152:2 Uncaught TypeError: Assignment to constant variable.
const aaaa='ss'
aaaa='dd'
console.log(aaaa)
// VM1194:2 Uncaught TypeError: Assignment to constant variable.
const aaaaa={aa:'dd'}
aaaaa={aa:'bb'}
console.log(aaaaa)
// VM1257:2 Uncaught TypeError: Assignment to constant variable.
const aaaaaa={aa:'dd'}
aaaaaa.aa='bb'
console.log(aaaaaa)
// {aa: "bb"}

 

标签:aa,console,log,修改,Uncaught,variable,const,属性
来源: https://www.cnblogs.com/HuiTaiLang1216/p/15777727.html