From 7e08b8cbd98a54c7acb8682a8873a6fecf674e1b Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Wed, 8 Nov 2023 15:24:30 +0100 Subject: [PATCH] An empty array is also returned when limit is 0 (#30103) --- .../javascript/reference/global_objects/string/split/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/javascript/reference/global_objects/string/split/index.md b/files/en-us/web/javascript/reference/global_objects/string/split/index.md index 908407948414bfd..624ddacd33881ed 100644 --- a/files/en-us/web/javascript/reference/global_objects/string/split/index.md +++ b/files/en-us/web/javascript/reference/global_objects/string/split/index.md @@ -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).