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!
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
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!