[Solved] Why is it valid to call new again here?


The first case is not an error because if a constructor returns a non-primitive value, it is returned instead of the object created. Therefore, simplified, following happens:

  1. A new object is created
  2. The new object’s internal __proto__ variable is set to Foo.specialConstructor.prototype
  3. Foo.specialConstructor is executed using the created object as a this variable
  4. Because Foo.specialConstructor returns a non-primitive value, it is returned by the new operator instead of the newly created object

The second case is an error because the new operator can only be used on functions.

solved Why is it valid to call new again here?