const PI = 3.14;
PI = 4;//error
es5声明常量
var obj ={
aa : 1,
bb: "abc"
};
Object.defineProperty(obj,"cc",{value:"testcc",writable:false});
console.log(obj.cc);//testcc
obj.cc=123;
console.log(obj.cc);//testcc
Object.defineProperty(window,"PI",{value:"3.1415",writable:false});
console.log(PI);//3.1415
PI=4;
console.log(PI);//3.1415