The "Class#getName" in JavaScript
The name of a JavaScript class can be obtained with the constructor
method.
The following code:
class Airhacks {
getName() {
return this.constructor.name;
}
}
console.log(new Airhacks().getName());
prints: Airhacks
.
See you at Web, MicroProfile and Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.