javascript get object property by end of property name code example
Example 1: javascript list class properties
function getClassProperties(instanceOfClass) {
const proto = Object.getPrototypeOf(instanceOfClass);
const names = Object.getOwnPropertyNames(proto);
return names.filter(name => name != 'constructor');
}
Example 2: get object name javascript
var a = {
name:'a',
'light': 'good',
'dark' : {
name: 'dark',
'black': 'bad',
'gray' : 'not so bad'
}
}
// This way you can do
console.log(a.name,a.dark.name);