Taking into account the fundamental built-in objects when used as constructors the specification says:
creates and initializes a new XYZ object when called as a constructor
IMHO, this sentence is too vague:
What text would you suggest?
@ljharb I would suggest something like this:
When the XYZ object is used as a constructor the following steps are taken:
- Let _O_ be the object returned calling
ObjectCreate(%XYZPrototype%)- Set property [[property1]] of _O_ to "value1"
- Set property [[property2]] of _O_ to "value2"
- return _O_
The "creates and initializes a new X object" portion is a non-normative note giving a human-readable summary. The actual steps taken when invoking these are given in the sections immediate following the non-normative notes.
For example, the steps taken when invoking the Number constructor are given in 20.1.1.1.
But it is not clear that what is described in 20.1.1.1 is also used when using the Number object as costructor. Infact here the specs says:
A Number object can be coerced to a number value by calling the Number constructor as a
function (20.1.1.1).
Meaning that 20.1.1.1 describes the Number object when NOT used as constructor.
No, 20.1.1.1 describes its behavior when invoked as a constructor as well. It branches in line 3, the NewTarget is undefined case is when it is invoked as a function.
Ok, got it. Thank you all.
More generally (and explicitly), 9.3 Built-in Function Objects says: "The behaviour specified for each built-in function via algorithm steps or other means is the specification of the function body behaviour for both [[Call]] and [[Construct]] invocations of the function."
Most helpful comment
The "creates and initializes a new X object" portion is a non-normative note giving a human-readable summary. The actual steps taken when invoking these are given in the sections immediate following the non-normative notes.
For example, the steps taken when invoking the Number constructor are given in 20.1.1.1.