Today, We want to share with you JavaScript Capitalize First Letter.In this post we will show you javascript capitalize, hear for javascript capitalize first letter of each word we will give you demo and example for implement.In this post, we will learn about how to capitalize the first letter in a string in javascript with an example.
JavaScript Capitalize First Letter
To Automatically write using JavaScript capitalize the first character of a your any string, We should to isolate mode the any string first character capitalize from the left of the message, and then 3 ways to concatenate it with some good Examples to the rest of the message.
javascript capitalize first letter Example – 1
[php]
var small_str = ‘how to capitalize the first letter in a string in javascript’;
var capitalize_str = small_str.charAt(0).toUpperCase() + small_str.substr(1);
[/php]
javascript capitalize Example – 2
Second Way, if We are comfortable with pure JavaScript regular expressions, We do simple things to change in capitalize first letter javascript Examples:
[php]
var capitalize_str = small_str.replace(/^\w/, function (chr) {
return chr.toUpperCase();
});
[/php]
capitalize first letter javascript Example – 3
Last Way, We can simple even take it one onther way to javascript capitalize by using more new syntax:
[php]
const capitalize_str = small_str.replace(/^\w/, c => c.toUpperCase());
[/php]
jQuery 15 Powerful Tips and Tricks for Developers and Web Designer
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about JavaScript Capitalize First Letter of each sentence Example.I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.