I am trying to learn JS and am confused about object properties, in the example below I have used an undefined function to generate an error and I am trying to get properties and methods of the error object. While e.message does print the error message I am not able to get message as error object property. What is happening here?
try{
unknownFunction();// undefined function here
}catch(e){
console.log(e); // it is ReferenceError
console.log(e.message);//message
console.log(typeof e); // object
console.log(e instanceof ReferenceError); // true
console.log(e === ReferenceError); // false
for(var propertyName in e) {
console.log("Name "+propertyName+" and Value "+e[propertyName]);
} // []
let allKeys = Object.keys(e);
console.log(allKeys);// []
let fnKeys = allKeys.filter(key => typeof myObj[key] == 'function');
console.log(fnKeys); // []
}