Catalin Vasile

I'm a design-focused engineer.

JavaScript Bits: How to capitalize the first letter of a String?

Capitalizing the first letter of a String type in JavaScript is quite easy. All you have to do is separate the first letter, make it uppercase and then concatenate it with the initial string, but without the first letter.

Here are two examples of how you can achieve this in both ES5 and ES6 using arrow functions.

// ES6
const upperFirstES6 = (str) => str.charAt(0).toUpperCase() + str.slice(1);

// ES5
function upperFirstES5(str) {
    return str.charAt(0).toUpperCase() + str.slice(1);

Here’s a quick sketch of how both functions above work:

javascript capitalize first letter


Be the first to know when I publish a new article on the blog.

No spam. You can unsubscribe at any time.