When a function is called with the new keyword, the function will be used as a constructor. new will do the following things:
- Creates a blank, plain JavaScript object. For convenience, let's call it newInstance.
newInstance.__proto__ = calledFunction.prototype
.calledFunction.call(newInstance)
.- If the constructor function returns a non-primitive, this return value becomes the result of the whole new expression. Otherwise, if the constructor function doesn't return anything or returns a primitive, newInstance is returned instead.