Split string into array of characters in JavaScript
In this tutorial, you are given a string, and you will learn how to split the string into an array of characters.
Solution
To split string str
into an array of characters in JavaScript, call String.split() method on the string str
, and pass empty string as separator
(argument).
str.split('')
Example
1. In the following program, we take a string value 'apple'
and split this string into array of characters.
let name = 'apple';
let output = name.split('');
console.log(output);