标签:property fun define div table else xiaomi java fine
Object.defineProperty(Object, ‘freezePolyfill‘, { value: function(obj) { var i; for (i in obj) { if (obj.hasOwnProperty(i)) { if(typeof(obj[i])===‘object‘){ Object.freezePolyfill(obj[i]); }else{ Object.defineProperty(obj, i, { writable: false }); } } } Object.seal(obj); } }); const xiaoming = { age: 14, name: ‘小明‘, obj: { a: 1 } }; Object.freezePolyfill(xiaoming);
实现当对象下的属性又是一个对象的时候,怎么来防止该对象下这个对象的属性被改变
标签:property fun define div table else xiaomi java fine
原文地址:https://www.cnblogs.com/rickdiculous/p/12153732.html