EN
JavaScript - convert string to character array
4
points
In this article, we would like to show you how to convert string to characters array in JavaScript.
1. Using String split()
method
// ONLINE-RUNNER:browser;
var text = 'ABCD';
var array = text.split('');
console.log(array);
2. Using Array.from()
method
// ONLINE-RUNNER:browser;
var text = 'ABCD';
var array = Array.from(text);
console.log(array);
3. Using Object.assign()
// ONLINE-RUNNER:browser;
var text = 'ABCD';
var array = Object.assign([], text);
console.log(array);