vadnica-logo
X

JavaScript String Properties and Methods: toUpperCase()

The toUpperCase() method returns a new string in which all characters are converted to uppercase. The original string remains unchanged. The conversion follows Unicode rules and is not locale-sensitive. For locale-sensitive conversions (e.g., Turkish İ/ı), use toLocaleUpperCase(locale). Calling it on null or undefined throws a TypeError.

EXAMPLE
RESULT

Below is an interactive example of changing letter case. Enter any text to see the result of toUpperCase() and the locale‑aware toLocaleUpperCase(locale). With the “Locale” selector you can check language‑specific behaviors (for example, Turkish: "i" → "İ", "ı" → "I"). The original value is not modified; results update live, and there is also an indicator showing whether the outputs are equal. Note: calling toUpperCase() or toLocaleUpperCase() on null/undefined throws a TypeError — always ensure you have a valid string first.

Hint: Turkish distinguishes “i/İ” and “ı/I”.
Original string:
typeof(original):
toUpperCase():
toLocaleUpperCase(locale):
Results are equal:

Notes

  • toUpperCase() does not take arguments; it returns a new string and leaves the original unchanged.
  • toLocaleUpperCase(locale) is locale‑sensitive; for example, in Turkish "i" → "İ" and "ı" → "I".
  • Calling it on null or undefined throws a TypeError — ensure a valid string first.

Thank you for visiting! Adding privacy policy.

© 2024 All rights reserved.

Vam je koda pomagala? Če želite podpreti moj trud pri pripravi vodičev in vzdrževanju strani, mi lahko namenite donacijo za kavo.