Skip to content

Commit

Permalink
Improve substring description (mdn#22559)
Browse files Browse the repository at this point in the history
The previous version of the text made it reasonable to assume that if the text would be "Mozilla" and the indexes `(1, 3)`, the end result will be the character `z`,
i.e. the string "between the start and end indexes".

Since that would be very unusual, many users might instead assume that it would result in `ozi`. But that would also be incorrect.

This change makes it clear that the function includes the first index and excludes the second.
  • Loading branch information
withrocks authored Nov 27, 2022
1 parent e0bc3b1 commit 507c05f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ browser-compat: javascript.builtins.String.substring

{{JSRef}}

The **`substring()`** method returns the part of the `string` between the start and end indexes, or to the end of the string.
The **`substring()`** method returns the part of the `string` from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.

{{EmbedInteractiveExample("pages/js/string-substring.html")}}

Expand Down

0 comments on commit 507c05f

Please sign in to comment.