Another method can be the instanceof operator which checks the type of an object at run time. It return a corresponding boolean value, for example, either true or false to indicate if the object is of a particular type or not:
let str = new String();
let date = new Date();
console.log(str instanceof Object);
console.log(str instanceof Date);
console.log(str instanceof String);
console.log(str instanceof Number);
console.log(date instanceof Date);
console.log(date instanceof Object);
console.log(date instanceof String);
console.log(date instanceof Number);
The typeof method appears to be the fastest in Chrome, but in Firefox the instanceof method is the winner.
The toString() Method
Another useful method is toString(). Each object has a toString() method, which is called when a value of string type is expected. If the method is not overridden, it will return the object type.
let str = arr.toString();
console.log("Showing string is : " + str );