'Why don't these error properties show under keys?
It seems from Object.getOwnPropertyNames vs Object.keys, that the main difference between Object.keys() and Object.getOwnPropertyNames() is that the former only returns some of the properties -- those that are enumerable. So I'm wondering for something like an Error object, why it's decided that the properties aren't enumerable. For example:
try {
let field="XYZ";
field.a.b.c;
} catch (error) {
console.log('111', Object.getOwnPropertyNames(error));
console.log('222', Object.keys(error));
}
Why for example does the Error object not make those properties enumerable? When is a property usually made enumerable?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
