Get characters of a string

The following line returns all characters of a given string:
const message = 'Hello';
const chars = [...message]; // ['H', 'e', 'l', 'l', 'o']
If you want to get the first and the remaining characters of a string, then use ES6 destructing:
const [first,] = message;
// first = 'H'
// rest = ['e', 'l', 'l', 'o']
We can use it to capitalize or decapitalize a string:
capitalize = ([first,]) => `${first.toUpperCase()}${rest.join('')}`;
decapitalize = ([first,]) => `${first.toLowerCase()}${rest.join('')}`;
capitalize('hello world'); // 'Hello world'

See also