The toUpperCase() method returns the string converted to uppercase.
Example
toUpperCase() Syntax
The syntax of the toUpperCase() method is:
str.toUpperCase()
Here, str is a string.
toUpperCase() Parameters
The toUpperCase() method does not take in any parameters.
toUpperCase() Return Value
- Returns a new string representing the calling string converted to uppercase.
Notes:
- The
toUpperCase()method raisesTypeErrorwhen called onnullorundefined. - The
toUpperCase()method does not change the original string.
Example: Using toUpperCase() method
Output
HELLO WORLD! JAVA IS TO JAVASCRIPT WHAT CAR IS TO CARPET.
Recommended Reading: JavaScript String toLowerCase()