- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript String split
JavaScript Strings
JavaScript String split
splitturns a string into an array by cutting it at a separator.
It is the opposite of join, which turns an array back into a string.
Together they let you use array methods on text.
Example
Example
javascript
const text = "a,b,c";
const parts = text.split(",");
console.log(parts.length);
console.log(parts[0]);The output is 3 then a.
