JavaScriptStringsplit

Divides a string into an ordered list of substrings.

Syntax

str.split(separator, limit?)

Example

Enter values below to update the example in real time.

const
csv
fruits
split
console
const csv = "apple,banana,cherry";
const fruits = csv.split(",");
console.log(fruits);   // ["apple", "banana", "cherry"]