Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editorial: Revert unintentional normative change for String.prototype…
….substr `"a".substr(0, Infinity)` should return `"a"`, but tc39#2007 incorrectly changed the result to be `""`. If we change `substr`'s algorithm to be more similar to `String.prototype.substring` and `String.prototype.slice`, we can easily fix this issue: 1. `min(intStart, size)` guarantees that `intStart` is now in `[0, size]`. 2. Clamping `intLength` guarantees it's also in `[0, size]`. With these two changes, `intEnd = min(intStart + intLength, size)` is now in range `[intStart, size]`, so we no longer have to check for `intStart ≥ intEnd`, but instead can directly perform the `substring` operation.
- Loading branch information