Skip to content

Instantly share code, notes, and snippets.

@mildronize
Created November 9, 2020 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mildronize/d7b170820e4bd0aed6b7a8b4f122d808 to your computer and use it in GitHub Desktop.
Save mildronize/d7b170820e4bd0aed6b7a8b4f122d808 to your computer and use it in GitHub Desktop.
Get class name without created the object (The constructor wasn't called)
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