const originalString = "Hello, World!";
const uppercaseStr = originalString.toUpperCase();

console.log(uppercaseStr); // 출력: "HELLO, WORLD!"

/* 👇 원본 문자열은 바뀌지 않습니다. */
console.log(originalString); // 출력: "Hello, World!"
str.toUpperCase();
const number = 17;

try {
    let result = number.toUpperCase(); // 이 부분에서 TypeError 발생
    console.log(result);
} catch (error) {
    console.error(error); // TypeError: number.toUpperCase is not a function
}
const str1 = "apple";
const str2 = "APPLE";

if (str1.toUpperCase() === str2.toUpperCase()) {
    console.log("두 문자열은 같습니다.");
} else {
    console.log("두 문자열은 다릅니다.");
}

// 출력: "두 문자열은 같습니다."
const title = "web development";
console.log(title.toUpperCase()); // 출력: "WEB DEVELOPMENT"
const warningMessage = "keep out of reach of children";
console.log(warningMessage.toUpperCase());
// 출력: "KEEP OUT OF REACH OF CHILDREN"
toUpperCase() 함수의 브라우저 호환성
메서드
데스크탑 Chrome
Chrome
데스크탑데스크탑 Edge
Edge
데스크탑 Firefox
Firefox
Safari
Safari
toUpperCase() 1 12 1 1

caniuse.com에서 더 자세한 정보를 확인해 보세요.