String to character array

JavaScript, String · Oct 8, 2020

Converts a string to an array of characters.

  • Use the spread operator (...) to convert the string into an array of characters.
const toCharArray = s => [...s];
toCharArray('hello'); // ['h', 'e', 'l', 'l', 'o']

More like this

  • HSL to array

    Converts an hsl() color string to an array of values.

    JavaScript, String · Oct 22, 2020

  • RGB to array

    Converts an rgb() color string to an array of values.

    JavaScript, String · Jun 13, 2021

  • CSV to array

    Converts a comma-separated values (CSV) string to a 2D array.

    JavaScript, String · Jan 30, 2022