JavaScript supports object-oriented programming, which means that you can create classes and objects, and use them to store data.
One useful thing to be able to know from an object is the name of the class it was created from.
In this post, we'll learn how you can get the class name of an object in JavaScript.
Getting the class name of an object
First let's start with a class and an object created from it.
JAVASCRIPT
classShape {}
const triangle = newShape();
Given the object triangle, we can get the class name of it using the constructor property, which returns a reference to the constructor function that created the object, then using the name property to get the name of the class.