110
rated 0 times
[
112]
[
2]
/ answers: 1 / hits: 29681
/ 9 Years ago, sun, march 8, 2015, 12:00:00
In the ES6, if I make a class and create an object of that class, how do I check that the object is that class?
I can't just use typeof
because the objects are still object
. Do I just compare constructors?
Example:
class Person {
constructor() {}
}
var person = new Person();
if ( /* what do I put here to check if person is a Person? */ ) {
// do stuff
}
More From » ecmascript-6