How to get the first letter of a string in JavaScript

Published Apr 11 2022

To get the first letter of a string in Javascript, the .charAt() method can be used. By passing the index 0, we specify that we want to return the first character of the string. Alternatives to this method include the .slice(),

substring() and substr () methods, or simply accessing the first element of the string using square bracket notation with the first index [0].

far out logo

Code Playground

Loading...
This was pretty far out... now tell me about Binary Search in JavaScript
Far Out Logo
That was pretty far out... but I want to learn about How to use the React useCallback() hook