Skip to content

Commit

Permalink
An empty array is also returned when limit is 0 (#30103)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Nov 8, 2023
1 parent 8681d02 commit 7e08b8c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If `separator` is a non-empty string, the target string is split by all matches

If `separator` is an empty string (`""`), `str` is converted to an array of each of its UTF-16 "characters", without empty strings on either ends of the resulting string.

> **Note:** `"".split("")` is therefore the only way to produce an empty array when a string is passed as `separator`.
> **Note:** `"".split("")` is therefore the only way to produce an empty array when a string is passed as `separator` and `limit` is not `0`.
> **Warning:** When the empty string (`""`) is used as a separator, the string is **not** split by _user-perceived characters_ ([grapheme clusters](https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)) or unicode characters (code points), but by UTF-16 code units. This destroys [surrogate pairs](https://unicode.org/faq/utf_bom.html#utf16-2). See ["How do you get a string to a character array in JavaScript?" on StackOverflow](https://stackoverflow.com/questions/4547609/how-to-get-character-array-from-a-string/34717402#34717402).
Expand Down

0 comments on commit 7e08b8c

Please sign in to comment.