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
Post a Comment