javascript - How to check if a variable is an ES6 class declaration? -


i exporting following es6 class 1 module:

export class thingy {   hello() {     console.log("a");   }    world() {     console.log("b");   } } 

and importing module:

import {thingy} "thingy";  if (isclass(thingy)) {   // something... } 

how can check whether variable class? not class instance, class declaration?

in other words, how implement isclass function in example above?

in es6, there no "class" when code running, have constructor function, or object. do

if (typeof thingy === 'function'){   // it's function, can't instance. } else {   // other constructor } 

as long know fact either instance or constructor.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -