constructor Property
Every object’s prototype has a constructor property that references the function used to create that object. It is useful for checking the origin of an instance or creating new instances of the same type.
Code Example
Section titled “Code Example”function User(name) { this.name = name;}const user = new User("Alice");console.log(user.constructor === User); // trueconsole.log(user.constructor.name); // "User"
// Create another user using constructorconst another = new user.constructor("Bob");console.log(another.name); // "Bob"