How to get the first character of a string in JavaScript?

To get the first character of a string in JavaScript, do this: string.charAt(0).

Here's how you do it:

const string = 'Hello World!';
const firstCharacter = string.charAt(0);

console.log(firstCharacter); // H