const sentence = "The quick brown fox jumps over the lazy dog.";
console.log(sentence.toUpperCase());
// Expected output: "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
Syntax Parameters
None.
Return valueA new string representing the calling string converted to upper case.
DescriptionThe toUpperCase()
method returns the value of the string converted to uppercase. This method does not affect the value of the string itself since JavaScript strings are immutable.
console.log("alphabet".toUpperCase()); // 'ALPHABET'
Conversion of non-string this
values to strings
This method will convert any non-string value to a string, when you set its this
to a value that is not a string:
const a = String.prototype.toUpperCase.call({
toString() {
return "abcdef";
},
});
const b = String.prototype.toUpperCase.call(true);
// prints out 'ABCDEF TRUE'.
console.log(a, b);
Specifications Browser compatibility
Loadingâ¦
See alsoString.prototype.toLocaleLowerCase()
String.prototype.toLocaleUpperCase()
String.prototype.toLowerCase()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5