How to Convert Strings to Uppercase with JavaScript?

Article By Digamber Rawat on

JavaScript offers a powerful method to convert string to uppercase; however, this can also be achieved with CSS. We simply store the string in variable and bind it with toUpperCase() method. It converts the string and returns the new value in uppercase form. As we know JavaScript strings are immutable, so it doesn’t affect the value of the string.

As far as the browser support is concerned this method is supported by almost every browser.

JavaScript’s toUpperCase() example.

let string = 'a part of the journey is the end.';

string.toUpperCase();
// output: "A PART OF THE JOURNEY IS THE END."

JavaScript toUpperCase() Syntax

str.toUpperCase()

str: attach a new string with the method; it will return the converted string to uppercase.

let string = 'hello this is dummy content';

let upper = string.toUpperCase();

console.log(upper)

// output: HELLO THIS IS DUMMY CONTENT
Digamber Rawat

Feel free to contact me, If you are looking for a freelance full stack Developer, with the following skills: Mongo DB, Express JS, Angualr 2+, Node JS, Loopback JS, Firebase, Ionic Framework and WordPress. I also offer remote contracting service to the clients across the globe. Hire Me