This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
In this article, you will learn how to convert string to array in Javascript.
Let’s say you have a string variable named ‘a’ with value “codesource”.
var a = "codesource";
In order to convert a string to an array, you can use the split() method.
var a = "codesource";
console.log(a.split(""));
Note: The split() method functions by splitting the string into an array of characters.
The post How to Convert String to Array in Javascript appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
Ariessa Norramli | Sciencx (2021-02-17T07:18:16+00:00) How to Convert String to Array in Javascript. Retrieved from https://www.scien.cx/2021/02/17/how-to-convert-string-to-array-in-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.