Utilizor
Contact Us

split

Converting a string to an array.

String split()

A string can be converted to an array with the split() method.

text.split(",") // Split on commas text.split(" ") // Split on spaces text.split("|") // Split on pipe

If the separator is omitted, the returned array will contain the whole string in index [0].

Example

let text = "a,b,c,d,e";
const myArray = text.split(",");