String split() method in JavaScript

The split() method in JavaScript enables us to break down a string into an array of (smaller) strings. Let’s jump directly into the code.


Example

string = "A-quick-brown-fox" //string to be split
array_of_strings = string.split("-") //The split() function
console.log(string) //note that the split function doesn't change the original string
console.log(array_of_strings)
Note that the breaking character is itself lost in the process
Note that the breaking character is itself lost in the process

The break character can be any available character. The codes below show the exact same task using space (" “) and empty (”") characters.

string = "A quick brown fox" //string to be split
array_of_strings = string.split(" ") //The split() function
console.log(string) //note that the split function doesn't change the original string
console.log(array_of_strings)
Using space character will divide the entire string into individual words
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved