estus estus - 1 month ago 9x
Javascript Question

Get the class name of ES6 class instance

Are there any 'harmonious' ways to get the class name from ES6 class instance? Other than

Currently I'm counting on Traceur implementation. And it seems that Babel has a polyfill for
while Traceur doesn't.

To sum it all up: there was no other way in ES6/ES2015/Harmony, and nothing is expected ATM in ES.Next.

It may provide useful patterns for unminified server-side applications but is unwanted in applications meant for browser/desktop/mobile.

Babel uses
to polyfill
, it should be loaded manually for Traceur and TypeScript applications as appropriate.

Answer is exactly the correct way to do this. Transpilers may not support this, but it is the standard way per the specification. (The name property of functions declared via ClassDeclaration productions is set in 14.5.15, step 6.)