Javascript string split() is an inbuilt function that is used to split the string into an array of the substring and returns a new collection.  If the empty string (“”) is used as the separator, the string is split between each character. The split() method does not mutate the original string.

Javascript string split example

The syntax is following for String Split Example.

string.split(separator, limit)

Syntax Explanation

Arguments

The first argument to the split function is the string which specifies the points where the split has to take place.

This argument can be treated as a simple string or as a regular expression. If the separator is unspecified, then the whole string becomes a single array element.

The same thing also happens when a separator is not present in the string. If the separator is an empty string (“”), then every character of the string is separated.

The second argument to a function limit defines an upper limit on the number of splits to be found in a given string. If a string remains unchecked after a threshold or limit is reached, then it is not reported in an array.

#javascript #javascript string.split #regular expression

Javascript String Split Example | Javascript String.split()
2.45 GEEK