Questions And Answers

More Tutorials

Javascript Convert a String to an Array

The .split() method splits a string into an array of substrings. By default .split() will break the string into substrings on spaces (" "), which is equivalent to calling .split(" ").

The parameter passed to .split() specifies the character, or the regular expression, to use for splitting the string.

To split a string into an array call .split with an empty string (""). Important Note: This only works if all of your characters fit in the Unicode lower range characters, which covers most English and most European languages. For languages that require 3 and 4 byte Unicode characters, slice("") will separate them.

var strArray = "StackOverflow".split("");


["S", "t", "a", "c", "k", "O", "v", "e", "r", "f", "l", "o", "w"]

Using the spread operator (...), to convert a string into an array

var strArray = [..."sky is blue"]; 


["s", "k", "y", " ", "i", "s", " ", "b", "l", "u", "e"]


In this page (written and validated by ) you learned about Javascript Convert a String to an Array . What's Next? If you are interested in completing Javascript tutorial, your next topic will be learning about: Javascript Removing items from an array.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.