📜  javascript 防止对象 MutationPassed - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:12.443000             🧑  作者: Mango

代码示例1
let obj = {
  name:"FreeCodeCamp"
  review:"Awesome"
};
Object.freeze(obj);
obj.review = "bad"; //will be ignored. Mutation not allowed
obj.newProp = "Test"; // will be ignored. Mutation not allowed
console.log(obj); 
// { name: "FreeCodeCamp", review:"Awesome"}