Files
30-seconds-of-code/snippets/to-char-array.md
2023-04-28 22:29:23 +03:00

372 B

title, type, tags, cover, dateModified
title type tags cover dateModified
String to character array snippet
string
waving-over-lake 2020-10-08T15:17:22+03:00

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']