Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
## typeof
Unary operator that returns a string indicating the type of the unevaluated operand.
```javascript
const a = "I'm a string primitive";
const b = new String("I'm a String Object");
typeof a; --> returns 'string'
typeof b; --> returns 'object'
```
## instanceof
Binary operator, accepting an object and a constructor.
It returns a boolean indicating whether or not the object has the given constructor in its prototype chain.
```javascript
const a = "I'm a string primitive";
const b = new String("I'm a String Object");
a instanceof String; --> returns false
b instanceof String; --> returns true
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.