split()

Breaks a string into a list of pieces.

What does split() do in JavaScript?

split() — Breaks a string into a list of pieces.

const words = "tea coffee".split(" ");
const label = words.join(" & ");

Level: Apprentice · More JavaScript terms at this level

Updated