Files
30-seconds-of-code/snippets/toCharArray.md
Isabelle Viktoria Maciohsek 27c168ce55 Bake date into snippets
2021-06-13 13:55:00 +03:00

19 lines
363 B
Markdown

---
title: toCharArray
tags: string,beginner
firstSeen: 2020-10-08T15:17:22+03:00
lastUpdated: 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.
```js
const toCharArray = s => [...s];
```
```js
toCharArray('hello'); // ['h', 'e', 'l', 'l', 'o']
```