String.prototype.toUpperCase()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015å¹´7æ.
toUpperCase() 㯠String å¤ã®ã¡ã½ããã§ãå¼ã³åºãæååã®å¤ãï¼æååã§ãªãå ´åãæååã«å¤æãã¦ï¼å¤§æåã«å¤æãã¦è¿ãã¾ãã
試ãã¦ã¿ã¾ããã
const sentence = "The quick brown fox jumps over the lazy dog.";
console.log(sentence.toUpperCase());
// äºæ³ãããçµæ: "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
æ§æ
js
toUpperCase()
弿°
ãªãã
è¿å¤
å¼ã³åºãæååã®å¤ã大æåã«å¤æããæ°ããæååã§ãã
解説
toUpperCase() ã¡ã½ããã¯ã大æåã«å¤æãããæååã®å¤ãè¿ãã¾ãããã®ã¡ã½ããã¯ãæååèªèº«ã®å¤ã«å½±é¿ãä¸ãã¾ããï¼JavaScript ã®æååã¯ä¸å¤ã§ãï¼ã
ä¾
>åºæ¬çãªä½¿ç¨
js
console.log("alphabet".toUpperCase()); // 'ALPHABET'
æååã§ãªã this å¤ãæååã«å¤æãã
ãã®ã¡ã½ãã㯠this ã«æååã§ãªãå¤ãè¨å®ããå ´åãæååã«å¤æãã¾ãã
js
const a = String.prototype.toUpperCase.call({
toString() {
return "abcdef";
},
});
const b = String.prototype.toUpperCase.call(true);
// 'ABCDEF TRUE' ã¨è¡¨ç¤º
console.log(a, b);
仿§æ¸
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-string.prototype.touppercase> |