How to Get a Class Name of an Object
As there is no direct getClass() method in JavaScript to get the object’s class name, you can use several options which will help you solve this problem.
typeof
The typeof operator returns a string that indicates the type of the unevaluated operand:
instanceof
The instanceof operator is used for checking whether the constructor's prototype property appears anywhere in the object's prototype chain. Use the name property of the constructor function to get the name of the class:
isPrototypeOf
The isPrototypeOf() method is used to check whether an object exists in another object's prototype chain:
prototype
You can use the prototype property for getting the name of the object class:
JavaScript Objects
The Object class represents one of the data types in JavaScript. It is used to store various keyed collections and complex entities. Almost all objects in JavaScript are instances of Object; a typical object inherits properties (as well as methods) from Object.prototype, though they may be overridden.