使用const的注意事项
1.const声明的标识符所绑定的值是不可再次改变的
2.ES6 const的其他行为和let一样
const BUFFER_SIZE = 1024;
let buffer = new ArrayBuffer(BUFFER_SIZE);
console.log(buffer);
let data = new Uint16Array(buffer);
let data2 = new Uint8Array(buffer);
data[0] = 0xff06;
console.log(data2[0],data2[1]);
//BUFFER_SIZE=1;报错
var A=Object.freeze({a:1});
A.a=2;
A.b=3;
console.log(A);
image.png
网友评论