I am looking for a way to get the name of an object property like this:
let o = {
first: 1,
second: 2
};
function q(prop) {
// return name of prop
}
console.log(q(o.first));
// should return "first"
I am not even sure this is possible, but I am just asking.
The main use case for this is given by dynamic specification of requested attributes while keeping the advantages of using intellisense which can be quite significant for large projects and refactoring purpose.
Aucun commentaire:
Enregistrer un commentaire