On this page
  1. String.split
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

String.split

Prev: slice | Up: String | Next: includes
Rel: String, String, RegExp & Intl Guide
Ref: MDN Web Docs — String.split
Tags: #public #web #javascript #builtins #string #tier/core


Signature & Overview

str.split(separator, limit?)

Splits str into an array of substrings using a string or RegExp delimiter.

Notes & Pitfalls

Example

console.assert(JSON.stringify("a,b,c".split(",")) === '["a","b","c"]');
console.assert(JSON.stringify("a,b,c".split(",", 2)) === '["a","b"]');

Linked from

Related notes