Example 1 — Split by a Separator
Cut on a delimiter, or into characters with an empty string.
const csv = "a,b,c";
console.log(csv.split(",")); // ["a", "b", "c"]
console.log("hello".split("")); // ["h", "e", "l", "l", "o"]
console.log("hi".split()); // ["hi"] How It Works
- Pick a delimiter.
split(",")cuts wherever a comma appears. - Empty separator.
split("")yields one entry per UTF-16 code unit. - Omit separator.
split()returns a one-element array with the whole string. - Source unchanged.
csvis still"a,b,c".

