Is it possible to get the object property name as a string
person = {};
person.first_name = \'Jack\';
person.last_name = \'Trades\';
person.address = {};
per
Using Proxy:
var propName = ( obj ) => new Proxy(obj, {
get(_, key) {
return key;
}
});
var person = {};
person.first_name = 'Jack';
person.last_name = 'Trades';
person.address = {};
person.address.street = 'Factory 1';
person.address.country = 'USA';
console.log(propName(person).first_name);
console.log(propName(person.address).country);