⚙ Compilation target
ES2024
⚙ Library
6.0.2
Missing / Incorrect Definition
String.split should allow undefined as its separator argument, resulting in an array containing the entire string.
Unlike the case of omitting the separator (#38331), this is a useful feature, since separator may be a variable, and it can be desirable to get an array with the entire string in the case that separator is not set, in order to not need a different code path for this case.
This feature is explicitly defined in the spec. It is not something that just 'happens to work', like using null or a number.
Sample Code
console.log("string,that could/split:but-should;not".split(undefined));
Documentation Link
https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.split
⚙ Compilation target
ES2024
⚙ Library
6.0.2
Missing / Incorrect Definition
String.split should allow undefined as its separator argument, resulting in an array containing the entire string.
Unlike the case of omitting the separator (#38331), this is a useful feature, since separator may be a variable, and it can be desirable to get an array with the entire string in the case that separator is not set, in order to not need a different code path for this case.
This feature is explicitly defined in the spec. It is not something that just 'happens to work', like using null or a number.
Sample Code
Documentation Link
https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.split