const originalString = "Hello, World!";
const lowercaseStr = originalString.toLowerCase();

console.log(lowercaseStr); // 출력: "hello, world!"

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

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

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

// 출력: "두 문자열은 같습니다."
const keywords = ["JavaScript", "HTML", "CSS"];
const userInput = "javascript";

const matchingKeywords = keywords.filter(keyword => {
    return keyword.toLowerCase() === userInput.toLowerCase();
});

console.log(matchingKeywords); // 출력: ["JavaScript"]
const originalFileName = "MyDocument.txt";
const normalizedFileName = originalFileName.toLowerCase();

console.log(normalizedFileName); // 출력: "mydocument.txt"
const data = [
  {name: "Hello"},
  {name: "HelloWorld"},
  {name: "hello"}
];

const normalizedData = data.map(item => {
    return {
        name: item.name.toLowerCase()
    };
});

console.log(normalizedData);
/*
출력:
    [
      {name: "hello"},
      {name: "helloworld"},
      {name: "hello"}
    ]
*/
toLowerCase() 함수의 브라우저 호환성
메서드
데스크탑 Chrome
Chrome
데스크탑데스크탑 Edge
Edge
데스크탑 Firefox
Firefox
Safari
Safari
toLowerCase() 1 12 1 1

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