Skip to content

Commit

Permalink
Add +0 to Array.prototype.indexOf to convert negative zero to positiv…
Browse files Browse the repository at this point in the history
  • Loading branch information
anba committed Jan 22, 2016
1 parent 70562e8 commit 5deb1e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -29368,7 +29368,7 @@ <h1>Array.from ( _items_ [ , _mapfn_ [ , _thisArg_ ] ] )</h1>
1. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_).
1. If _defineStatus_ is an abrupt completion, return ? IteratorClose(_iterator_, _defineStatus_).
1. Increase _k_ by 1.
1. Note: _items_ is not an Iterable so assume it is an array-like object.
1. NOTE: _items_ is not an Iterable so assume it is an array-like object.
1. Let _arrayLike_ be ! ToObject(_items_).
1. Let _len_ be ? ToLength(? Get(_arrayLike_, `"length"`)).
1. If IsConstructor(_C_) is *true*, then
Expand Down Expand Up @@ -29809,7 +29809,8 @@ <h1>Array.prototype.indexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Let _n_ be ? ToInteger(_fromIndex_). (If _fromIndex_ is *undefined*, this step produces the value 0.)
1. If _n_ &ge; _len_, return -1.
1. If _n_ &ge; 0, then
1. Let _k_ be _n_.
1. Let _k_ be _n_ + (*+0*).
1. NOTE: Adding a positive zero converts *-0* to *+0*.
1. Else _n_ &lt; 0,
1. Let _k_ be _len_ + _n_.
1. If _k_ &lt; 0, let _k_ be 0.
Expand Down Expand Up @@ -29879,7 +29880,9 @@ <h1>Array.prototype.lastIndexOf ( _searchElement_ [ , _fromIndex_ ] )</h1>
1. Let _len_ be ? ToLength(? Get(_O_, `"length"`)).
1. If _len_ is 0, return -1.
1. If argument _fromIndex_ was passed, let _n_ be ? ToInteger(_fromIndex_); else let _n_ be _len_-1.
1. If _n_ &ge; 0, let _k_ be min(_n_, _len_ - 1).
1. If _n_ &ge; 0, then
1. Let _k_ be min(_n_, _len_ - 1).
1. NOTE: Applying the mathematical function min(&hellip;) converts *-0* to *+0*.
1. Else _n_ &lt; 0,
1. Let _k_ be _len_ + _n_.
1. Repeat, while _k_ &ge; 0
Expand Down Expand Up @@ -30977,7 +30980,7 @@ <h1>Runtime Semantics: IterableToArrayLike( _items_ )</h1>
1. Let _nextValue_ be ? IteratorValue(_next_).
1. Append _nextValue_ to the end of the List _values_.
1. Return CreateArrayFromList(_values_).
1. Note: _items_ is not an Iterable so assume it is already an array-like object.
1. NOTE: _items_ is not an Iterable so assume it is already an array-like object.
1. Return ! ToObject(_items_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 5deb1e5

Please sign in to comment.