Object.freeze() 冻结变量--引用类型

const HOST = {
    port:22
    }
Host.port = 33;
console.log( Host ) //{ port: 33};

const HOST1 = {
   port:80 
}
Object.freeze(HOST1);
HOST1.port = 90;
console.log(HOST1) //{ port:80};

 

posted @ 2020-04-02 17:28  砂糖一椰子  阅读(189)  评论(0编辑  收藏  举报