Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify ToIndex, ToLength, and ToIntegerOrInfinity #2501

Merged
merged 3 commits into from
Sep 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -5037,12 +5037,12 @@ <h1>
<emu-clause id="sec-tointegerorinfinity" type="abstract operation" oldids="sec-tointeger">
<h1>
ToIntegerOrInfinity (
_argument_: unknown,
_argument_: an ECMAScript language value,
)
</h1>
<dl class="header">
<dt>description</dt>
<dd>It converts _argument_ to an integer, +&infin;, or -&infin;.</dd>
<dd>It converts _argument_ to an integer representing its Number value with fractional part truncated, or to +&infin; or -&infin; when that Number value is infinite.</dd>
</dl>
<emu-alg>
1. Let _number_ be ? ToNumber(_argument_).
Expand Down Expand Up @@ -5582,12 +5582,12 @@ <h1>
<emu-clause id="sec-tolength" type="abstract operation">
<h1>
ToLength (
_argument_: unknown,
_argument_: an ECMAScript language value,
)
</h1>
<dl class="header">
<dt>description</dt>
<dd>It converts _argument_ to an integral Number suitable for use as the length of an array-like object.</dd>
<dd>It clamps _argument_ to an integral Number suitable for use as the length of an array-like object.</dd>
</dl>
<emu-alg>
1. Let _len_ be ? ToIntegerOrInfinity(_argument_).
Expand Down Expand Up @@ -5618,22 +5618,22 @@ <h1>
<emu-clause id="sec-toindex" type="abstract operation">
<h1>
ToIndex (
_value_: unknown,
_value_: an ECMAScript language value,
)
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns _value_ argument converted to a non-negative integer if it is a valid integer index value.</dd>
<dd>It converts _value_ to a non-negative integer if the corresponding decimal representation, as a String, is an integer index.</dd>
</dl>
<emu-alg>
1. If _value_ is *undefined*, then
1. Return 0.
1. Else,
1. Let _integerIndex_ be 𝔽(? ToIntegerOrInfinity(_value_)).
1. If _integerIndex_ &lt; *+0*<sub>𝔽</sub>, throw a *RangeError* exception.
1. Let _index_ be ! ToLength(_integerIndex_).
1. If ! SameValue(_integerIndex_, _index_) is *false*, throw a *RangeError* exception.
1. Return ℝ(_index_).
1. Let _integer_ be ? ToIntegerOrInfinity(_value_).
1. Let _clamped_ be ! ToLength(𝔽(_integer_)).
1. If ! SameValue(𝔽(_integer_), _clamped_) is *false*, throw a *RangeError* exception.
1. Assert: 0 &le; _integer_ &le; 2<sup>53</sup> - 1.
1. Return _integer_.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down