Introduction
In JavaScript, there are situations when we wish to make the first letter of a string uppercase.
In this article, we'll learn how to uppercase first letter of a string in JavaScript;
How to make the first letter of a string uppercase in JavaScript
To make the first letter of a string uppercase in modern JavaScript we can use the toLocalUpperCase()
method:
In older browsers, we can simply take the first letter of a string and call toUpperCase()
on it. This first uppercased letter is concatenated with the rest of a string:
Conclusion
To make the first letter of a string uppercase in JavaScript we can use the toLocalUpperCase()
method with string destructuring. We can also use destructuring to to remove a property from an object.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}