You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • As far as I know there's nothing built-in, since the name of the object isn't actually stored in the object itself in Espruino.

    However if the class is something that's defined in the global scope, like SPI, then you can do:

    >x = new SPI()
    =SPI: {  }
    >Object.keys(global).find(n=>global[n]==­x.constructor)
    ="SPI"
    

    But if you know what you're looking for, you're far better off going with @AkosLukacs's suggestion as it's far faster and neater!

About

Avatar for Gordon @Gordon started