Datatypes in JavaScript

1) typeof : typeof is the function use to get the type in js.

boolean only true and false are allowed for boolean
type of null is also object

functions are also object in js but typeof shows strange
behaviour in case of null and function
null also return "function" , i consider it as datatype as it only accepts null as a only value

2) Finding an object’s class

To find whether a object was constructed by by a certain constructor or one inheriting from it , we can use instanceof keyword

console.log(2 instanceof  Number)       //false
console.log('abc' instanceof String) //false
console.log(true instanceof Boolean) //false
console.log(Symbol() instanceof Symbol) //false
Note:- primitive values are not considered as instance of any class

Every value in JS besides null and undefined also has a constructor property storing the function that was used to construct it. This even works with primitive

(that).constructor stores the function which is used to create "that" object"5" is not a instanceOf String then how it can be created by String constructor ? Reason is that JS use Wrapper classes to provide provide object 
functionality to primitive variables.
console.log("5" instanceof String) // false
console.log("5".constructor === String) // true

3) Getting object type by constructor name

with typeof operator one gets type “object” it falls into somewhat wast category in other words what type of “object” is actually it. One way to do it is to use object constructor name to get what falvour of object is actually it.

Argument pass to function is value or constructor for which we are trying to find object

Bonus : Polyfill for isNumber

function isNumber(value)
//null.constructor and undefined.constructor throw an error
if(value === null || value === undefined) return false
return value.constructor === Number

I am programmer and web developer who loves to teach