String.prototype.toUpperCase
Converts a string to uppercase.
Available since: ES1
Syntax
str.toUpperCase()Return value
stringA new string with every letter uppercased.
Examples
Works with letters of any alphabet:
console.log('hello, World'.toUpperCase());Output:
HELLO, WORLDThe reverse method is toLowerCase():
console.log('HELLO, World'.toLowerCase());Output:
hello, worldNotes
The original string is not modified — store the result in a variable.
See also
- String.prototype.includes — Checks whether a string contains a given substring.
- String.prototype.toLowerCase — Converts a string to lowercase.
- String.prototype.localeCompare — Compares strings by language rules — for alphabetical sorting.
Related recipes
In the tutorial
- String methods — Useful string methods in JavaScript: finding a position, reading characters, padStart, repeat, split and join, method chains.