Files
30-seconds-of-code/snippets/toCharArray.md

287 B

title, tags
title tags
toCharArray string,beginner

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