When we create a new object in javascript using the new or {} operator, the new property of the constructor of the object points to the constructor function. In your case:
firstUser = new User("Richard", " Richard@examnple.com ");
firstUser.constructor - User . The same is true for your User.prototype . When you use {} to create a new object for User.prototype , the property of the Object constructor. When you put constructor: User , you simply change the constructor property from Object to User , and your code still works.
source share