What method converts a string to all uppercase letters in JavaScript?
Answer
toUpperCase()
Answer
toUpperCase()
The `toUpperCase()` method converts a JavaScript string to uppercase letters. It returns a new string, so code such as `"hello".toUpperCase()` produces `"HELLO"` while leaving the original string unchanged.
This behavior follows from JavaScript strings being immutable primitive values: string methods do not rewrite the existing string in place. To keep the converted result, a program must assign it to a variable or use it directly, for example in a comparison, display operation, or form-processing routine.
A frequent mistake is expecting methods named `uppercase()`, `capitalize()`, or `toUpper()`; those are not standard JavaScript String methods. `toUpperCase()` changes lowercase letters throughout the string, but it does not capitalize only the first character. For locale-sensitive casing, JavaScript also provides `toLocaleUpperCase()`.
Source: Wikipedia · fact-checked Aug. 2026