Playgroud:
Created
November 9, 2020 02:36
-
-
Save mildronize/d7b170820e4bd0aed6b7a8b4f122d808 to your computer and use it in GitHub Desktop.
Get class name without created the object (The constructor wasn't called)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cat{ | |
constructor(){ | |
console.log('Cat object created'); | |
} | |
} | |
let instanceTemplate = Object.create(Cat.prototype); | |
console.log(instanceTemplate.constructor.name); | |
/* | |
Output: | |
Cat | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment