I was looking for a solution and had to come up with one myself.
I wanted to use something like c#'s nameof so my func is called as such.
function nameof(obj) {
return Object.keys(obj)[0];
}
Can be used like
const myObj = {};
nameof({ myObj }); // will return 'myObj'