Javascript String toUpperCase()

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 raises TypeError when called on null or undefined.
  • 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()