split & join in JavaScript
split and join are inverses across the string/array boundary: "a,b,c".split(",") makes ["a","b","c"], and ["a","b","c"].join(",") remakes the string. Split accepts strings or regex (with limit caps), join accepts any separator — together they tokenize, transform (via array methods between), and reassemble.
Edge behaviors to know: splitting "" gives [""], consecutive delimiters yield empty strings ("a,,b".split(",") has three parts), and join coerces elements (null/undefined become empty). CSV with quoted commas needs a real parser — split can't see quoting.
split tokenizes
"a,b,c".split(",") → three parts; string or regex separator plus optional limit.
join reassembles
["a","b"].join("-") → "a-b" — any separator, elements coerced, no trailing separator.
Transform between
s.split(" ").map(...).join(" ") — tokenize, process as arrays, rejoin: the text pipeline shape.
Know the edges
Empty strings, consecutive delimiters, quoted commas — each breaks naive splitting differently.
let csv = "ada,36,dev";let parts = csv.split(",");console.log(parts.length, parts[0]);console.log(parts.join(" | "));Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in JavaScript yourself — building beats watching.