📅  最后修改于: 2023-12-03 15:20:21.613000             🧑  作者: Mango
The String.toLower()
method is a built-in JavaScript function that converts the given string to lowercase and returns the resulting string. It does not modify the original string, but instead creates a new string with all the alphabetical characters converted to lowercase.
string.toLower()
The toLower()
method returns a new string with all the alphabetical characters converted to lowercase.
const str = "HELLO World";
const lowerStr = str.toLower();
console.log(lowerStr); // Output: "hello world"
In the above example, the toLower()
method is called on the str
string, which converts all the uppercase letters to lowercase, resulting in the new string "hello world". The original string remains unchanged.
toLower()
method only converts alphabetical characters to lowercase. Non-alphabetical characters such as numbers and special characters are not affected.toLower()
method returns the same string, as there is no conversion required.The toLower()
method is supported in all major browsers, including Chrome, Firefox, Safari, and Edge.
Note: It is important to note that the
toLower()
method is case-sensitive. If you want to perform a case-insensitive conversion, you can use thetoLowerCase()
method instead.
For more information, you can refer to the MDN web docs on String.toLower()
method.