Object.defineProperty
let obj = {
a: 1,
b: 2
};
Object.prototype.c = 3;
Object.defineProperty(obj, 'd', {
enumerable: false
});
for (let key in obj) {
console.log(key);
}
//输出 :
a
b
c
let obj = {
a: 1,
b: 2
};
Object.prototype.c = 3;
Object.defineProperty(obj, 'd', {
enumerable: false
});
for (let key in obj) {
console.log(key);
}
//输出 :
a
b
c