panzerdp / dmitripavlutin.com-comments

7 stars 0 forks source link

javascript-typeof-instanceof/ #95

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Type checking in JavaScript: typeof and instanceof operators

How to perform type checking in JavaScript using typeof and instanceof operators.

https://dmitripavlutin.com/javascript-typeof-instanceof/

Dimasprog commented 3 years ago

Quiz: What is the built-in constructor for which instanceof for any object returns true?

Default constructor

panzerdp commented 3 years ago

Quiz: What is the built-in constructor for which instanceof for any object returns true?

Default constructor

Nope. :)

RolandDreger commented 3 years ago

new Boolean() instanceof Object // true new String() instanceof Object // true new Number() instanceof Object // true Object(Symbol()) instanceof Object // true ;) new Date() instanceof Object // true [] instanceof Object // true (() => {}) instanceof Object // true

panzerdp commented 3 years ago

new Boolean() instanceof Object // true new String() instanceof Object // true new Number() instanceof Object // true Object(Symbol()) instanceof Object // true ;) new Date() instanceof Object // true [] instanceof Object // true (() => {}) instanceof Object // true

Exactly!