The expression new Gadget('phone') is not merely an instance factory. It performs four observable operations: allocates an object, links its prototype, invokes Gadget with that object as this, and decides whether the constructor's return value replaces it. section 6.1.1
Reason about new in this order:
- Create a new ordinary object. section 6.1.1
- Set the object's internal [[Prototype]] to the constructor's current prototype property. section 6.1.1
- Call the constructor with the new object bound as this, so assignments such as this.name = value affect that object. section 6.1.1
- Return the created object unless the constructor returns an object; primitive returns and no return value leave the created object as the result. section 6.1.1
function simulateNew(Constructor, ...args) {
const obj = Object.create(Constructor.prototype); #A
const result = Constructor.call(obj, ...args); #B
return result instanceof Object ? result : obj; #C
}
const g1 = new Gadget('phone'); #D
const g2 = simulateNew(Gadget, 'phone'); #DA compact simulation exposes the mechanism: Object.create establishes the prototype, Constructor.call supplies this, and the final test selects the expression result. section 6.1.1
When the constructor replaces the result
A constructor that returns { b: 2 } discards the initialized this object, while one that returns 42 does not. Returning a cached object or Proxy is possible, but uncommon. section 6.1.1
new.target distinguishes construction from an ordinary call: it is undefined without new and refers to the called function with new. Classes enforce construction automatically, while older constructor-style APIs may guard or redirect calls themselves. section 6.1.2
Prototype choice is time-sensitive: changing Constructor.prototype affects later instances, not objects already created. A null prototype therefore produces an object inheriting from nothing. section 6.1.1



