79627455

Date: 2025-05-18 12:45:13
Score: 1
Natty:
Report link

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'
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Orhan Ekici