Skip to main content Accessibility Feedback



Convert a string into an array by splitting it after a specific character (or characters).

The first argument, the delimiter, the character or characters to split by. As an optional second argument, you can stop splitting your string after a certain number of delimiter matches have been found.

let shoppingList = 'Soda, turkey sandwiches, potato chips, chocolate chip cookies';
let menu = shoppingList.split(', ');
let limitedMenu = shoppingList.split(', ', 2);

// logs ["Soda", "turkey sandwiches", "potato chips", "chocolate chip cookies"]

// logs ["Soda", "turkey sandwiches"]