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 July 2015.
String
값의 toUpperCase()
메서드는 문자열을 대문자로 변환해 반환합니다.
시도해보기
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."
구문
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® 2025 Language Specification # sec-string.prototype.touppercase |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toUpperCase |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.