There are several functions in JavaScript which can be used to split a string.

1. Split - (Split a string into an array of substrings)

var str = "This is a string";

var str = "This is a string";
    var res = str.split(" ");
    console.log(res);

It is important that split gives back an array with the string chunks.

2. Substr - (Extract parts of a string)

    var str = "This is a string";
    var res = str.substr(1, 4);
    console.log(res);

3. Substring - (Extract characters from a string)

    var str = "This is a string";
    var res = str.substring(1, 4);
    console.log(res);

Reference

W3Schools Split
W3Schools Substr
W3Schools Substring

Answer from squancy on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › jsref_split.asp
JavaScript String split() Method
The split() method splits a string into an array of substrings.
🌐
W3Schools
w3schools.com › js › tryit.asp
JavaScript String Methods
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › split
String.prototype.split() - JavaScript | MDN
The pattern describing where each split should occur. Can be undefined, a string, or an object with a Symbol.split method — the typical example being a regular expression. Omitting separator or passing undefined causes split() to return an array with the calling string as a single element.
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › jsref › jsref_split.asp.html
JavaScript String split() Method
The split() method is used to split a string into an array of substrings, and returns the new array.
🌐
W3Schools Blog
w3schools.blog › home › symbol.split javascript
Symbol.split JavaScript - W3schools
June 6, 2019 - <!DOCTYPE html> <html> <body> <script> class SplitTest { constructor(value) { this.value = value; } [Symbol.split](string) { var index = string.indexOf(this.value); return this.value + string.substr(0, index) + "/" + string.substr(index + this.value.length); } } document.write('w3schools'.split(new SplitTest('java'))); </script> </body> </html>
🌐
W3Schools
w3schools.com › jsref › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
Find elsewhere
🌐
Medium
medium.com › nerd-for-tech › basics-of-javascript-string-split-method-4647aa1b0f4e
Basics of Javascript · String · split() (method) | by Jakub Korch | Nerd For Tech | Medium
June 20, 2021 - Therefore our emoji symbol is split into its code unit values as we see in the output. If we use regular expression, the exact match has to be found, otherwise the result is an array with one element consisting of the entire string.
🌐
Programiz
programiz.com › javascript › library › string › split
JavaScript String split()
// only split string to maximum to parts let newText1 = text.split(pattern1, 2); console.log(newText1); // [ 'Java is awesome', ' Java is fun' ] const text2 = "JavaScript ; Python ;C;C++";
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript string methods › string.prototype.split()
JavaScript String split(): Splitting a String into Substrings
November 3, 2024 - In this tutorial, you'll learn how to use the JavaScript split() method to split a string into an array of substrings.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-split-method
JavaScript String split() Method - GeeksforGeeks
It returns an array and does not change the original string. An optional limit parameter can be used to control the number of splits. ... separator: It is used to specify the character, or the regular expression, to use for splitting the string. If the separator is unspecified then the entire string becomes one single array element.
Published   December 27, 2017
🌐
W3Schools
w3schools.com › jsref › jsref_slice_string.asp
JavaScript String slice() Method
break class const continue debugger do...while for for...in for...of function if...else let return switch throw try...catch var while JS Strings · at() charAt() charCodeAt() codePointAt() concat() constructor endsWith() fromCharCode() includes() indexOf() isWellFormed() lastIndexOf() length localeCompare() match() matchAll() padEnd() padStart() prototype repeat() replace() replaceAll() search() slice() split() startsWith() substr() substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase() toString() toUpperCase() toWellFormed() trim() trimEnd() trimStart() valueOf() JS Typed Arrays
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript string split method
JavaScript String Split Method Explained
September 1, 2008 - Learn how to use the JavaScript String split method to divide a string into an array of substrings based on a specified delimiter. Explore examples and syntax for effective string manipulation.
🌐
Sentry
sentry.io › sentry answers › javascript › split a string in javascript
Split a string in JavaScript | Sentry
const myString = "This is a sentence."; const words = myString.split(" "); // split on single space characters console.log(words); // will output ["This", "is", "a", "sentence."] The separator can be a string or a regular expression, so we could also do something like this:
🌐
Codecademy
codecademy.com › docs › javascript › strings › .split()
JavaScript | Strings | .split() | Codecademy
June 9, 2025 - This example uses the .split() method without the limit parameter to split the stringOfNames string into an array of names: const stringOfNames = 'Dominic, Shelly, Luka, Devin';
🌐
ReqBin
reqbin.com › code › javascript › wyqvcilw › javascript-split-string-example
How do I split a string in JavaScript?
To split a string in JavaScript, you can use the string.split(separator, limit) method. The split() method splits the given string into an array of strings using "separator" as the delimiter.