You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The [[Call]] internal method of an ECMAScript function object _F_ takes arguments _thisArgument_ (an ECMAScript language value) and _argumentsList_ (a List of ECMAScript language values). It performs the following steps when called:</p>
10734
10734
<emu-alg>
10735
10735
1. Assert: _F_ is an ECMAScript function object.
10736
-
1. If _F_.[[IsClassConstructor]] is *true*, throw a *TypeError* exception.
10737
10736
1. Let _callerContext_ be the running execution context.
10738
10737
1. Let _calleeContext_ be PrepareForOrdinaryCall(_F_, *undefined*).
10739
10738
1. Assert: _calleeContext_ is now the running execution context.
10739
+
1. If _F_.[[IsClassConstructor]] is *true*, then
10740
+
1. Let _error_ be a newly created *TypeError* object.
10741
+
1. NOTE: _error_ is created in _calleeContext_ with _F_'s associated Realm Record.
10742
+
1. Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context.
1. Let _result_ be OrdinaryCallEvaluateBody(_F_, _argumentsList_).
10742
10746
1. [id="step-call-pop-context-stack"] Remove _calleeContext_ from the execution context stack and restore _callerContext_ as the running execution context.
<p>The abstract operation MakeConstructor takes argument _F_ (a function object) and optional arguments _writablePrototype_ (a Boolean) and _prototype_ (an Object). It converts _F_ into a constructor. It performs the following steps when called:</p>
10916
10920
<emu-alg>
10917
-
1. Assert: _F_ is an ECMAScript function object.
10918
-
1. Assert: IsConstructor(_F_) is *false*.
10919
-
1. Assert: _F_ is an extensible object that does not have a *"prototype"* own property.
10920
-
1. Set _F_.[[Construct]] to the definition specified in <emu-xref href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget"></emu-xref>.
10921
+
1. Assert: _F_ is an ECMAScript function object or a built-in function object.
10922
+
1. If _F_ is an ECMAScript function object, then
10923
+
1. Assert: IsConstructor(_F_) is *false*.
10924
+
1. Assert: _F_ is an extensible object that does not have a *"prototype"* own property.
10925
+
1. Set _F_.[[Construct]] to the definition specified in <emu-xref href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget"></emu-xref>.
10921
10926
1. Set _F_.[[ConstructorKind]] to ~base~.
10922
10927
1. If _writablePrototype_ is not present, set _writablePrototype_ to *true*.
<p>The abstract operation CreateBuiltinFunction takes arguments _steps_, _length_, _name_, and _internalSlotsList_ (a List of names of internal slots) and optional arguments _realm_, _prototype_, and _prefix_. _internalSlotsList_ contains the names of additional internal slots that must be defined as part of the object. This operation creates a built-in function object. It performs the following steps when called:</p>
11156
11161
<emu-alg>
11157
11162
1. Assert: _steps_ is either a set of algorithm steps or other definition of a function's behaviour provided in this specification.
11158
-
1. If _realm_ is not present, set _realm_ to the current Realm Record.
11163
+
1. If _realm_ is not present or _realm_ is ~empty~, set _realm_ to the current Realm Record.
11159
11164
1. Assert: _realm_ is a Realm Record.
11160
11165
1. If _prototype_ is not present, set _prototype_ to _realm_.[[Intrinsics]].[[%Function.prototype%]].
11161
11166
1. Let _func_ be a new built-in function object that when called performs the action described by _steps_. The new function object has internal slots whose names are the elements of _internalSlotsList_, and an [[InitialName]] internal slot.
<p>When a Default Constructor Function is called with zero or more arguments which form the rest parameter ..._args_, the following steps are taken:</p>
20739
+
<emu-alg>
20740
+
1. If NewTarget is *undefined*, throw a *TypeError* exception.
20741
+
1. Let _F_ be the active function object.
20742
+
1. If _F_.[[ConstructorKind]] is ~derived~, then
20743
+
1. NOTE: This branch behaves similarly to `constructor(...args) { super(...args); }`. The most notable distinction is that while the aforementioned ECMAScript source text observably calls the @@iterator method on `%Array.prototype%`, a Default Constructor Function does not.
20744
+
1. Let _func_ be ! _F_.[[GetPrototypeOf]]().
20745
+
1. If IsConstructor(_func_) is *false*, throw a *TypeError* exception.
20746
+
1. Return ? Construct(_func_, _args_, NewTarget).
20747
+
1. Else,
20748
+
1. NOTE: This branch behaves similarly to `constructor() {}`.
<p>When the `toString` method is called, the following steps are taken:</p>
25190
25208
<emu-alg>
25191
25209
1. Let _func_ be the *this* value.
25192
-
1. If _func_ is a <emu-xref href="#sec-built-in-function-objects">built-in function object</emu-xref>, return an implementation-defined String source code representation of _func_. The representation must have the syntax of a |NativeFunction|. Additionally, if _func_ has an [[InitialName]] internal slot and _func_.[[InitialName]] is a String, the portion of the returned String that would be matched by |NativeFunctionAccessor?| |PropertyName| must be the value of _func_.[[InitialName]].
25193
25210
1. If Type(_func_) is Object and _func_ has a [[SourceText]] internal slot and _func_.[[SourceText]] is a sequence of Unicode code points and ! HostHasSourceTextAvailable(_func_) is *true*, then
1. If _func_ is a <emu-xref href="#sec-built-in-function-objects">built-in function object</emu-xref>, return an implementation-defined String source code representation of _func_. The representation must have the syntax of a |NativeFunction|. Additionally, if _func_ has an [[InitialName]] internal slot and _func_.[[InitialName]] is a String, the portion of the returned String that would be matched by |NativeFunctionAccessor?| |PropertyName| must be the value of _func_.[[InitialName]].
25195
25213
1. If Type(_func_) is Object and IsCallable(_func_) is *true*, return an implementation-defined String source code representation of _func_. The representation must have the syntax of a |NativeFunction|.
0 commit comments