javascript – How to transform string into character array?

Question:

Is it possible to transform string into character array?

I just found it with the .split(param); method .split(param);

I would like to convert a string into an array of characters , one character at each index.

I would like 'oi' if it converts to var[0] = 'o', var[1] = 'i'

How to do this?

Answer:

To separate a String by characters you can use '' as a separator.

var string = 'oi';
var array = string.split(''); // ["o", "i"]
Scroll to Top