Home  >  Article  >  Web Front-end  >  How to convert uppercase letters to lowercase in javascript

How to convert uppercase letters to lowercase in javascript

青灯夜游
青灯夜游Original
2021-11-26 17:31:3021277browse

Javascript method to convert uppercase letters to lowercase: 1. Use toLowerCase(), syntax "string.toLowerCase()"; 2. Use toLocaleLowerCase(), syntax "string.toLocaleLowerCase()".

How to convert uppercase letters to lowercase in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Javascript method to convert uppercase letters to lowercase:

Method 1: Use toLowerCase()

toLowerCase() method is used to convert strings to lowercase.

Syntax:

string.toLowerCase()

Return value:

  • A new string in which all uppercase characters in string are converted to lowercase characters.

var str="HELLO WORLD!"
document.write(str.toLowerCase())

How to convert uppercase letters to lowercase in javascript

Method 2: Use toLocaleLowerCase()

toLocaleLowerCase() method according to the language of the local host The environment converts the string to lowercase. Local is determined based on the browser's language settings.

Syntax:

string.toLocaleLowerCase()

Return value:

  • A new string in which all uppercase characters of string are converted to Lowercase characters.

var str="HELLO WORLD!"
console.log(str.toLocaleLowerCase());

How to convert uppercase letters to lowercase in javascript

Note:

Different from toLowerCase(), the toLocaleLowerCase() method converts the string to lower case. Only a few languages ​​(such as Turkish) have local case mapping, so the return value of this method is usually the same as toLowerCase().

[Related recommendations: javascript learning tutorial]

The above is the detailed content of How to convert uppercase letters to lowercase in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn