How to get the first character of a string?

Can anyone tell me how I can get the first character of a string? I want to check the first character from an input field.

let testString = $('input').val();

There are a lot of ways in JavaScript that you can use. You can use any of the examples below but be careful as they can give different outputs for an empty string.

var string = "hello world";
console.log(string.slice(0,1));     // h
console.log(string.charAt(0));      // h
console.log(string.substring(0,1)); // h
console.log(string.substr(0,1));    // h
console.log(string[0]);             // h
console.log(;          // h

var string = "";
console.log(string.slice(0,1));     // (an empty string)
console.log(string.charAt(0));      // (an empty string)
console.log(string.substring(0,1)); // (an empty string)
console.log(string.substr(0,1));    // (an empty string)
console.log(string[0]);             // undefined
console.log(;          // undefined