Home > Web Front-end > JS Tutorial > How to convert string case in javascript

How to convert string case in javascript

青灯夜游
Release: 2023-01-05 16:07:49
Original
9464 people have browsed it

Javascript string case conversion method: 1. Use toLocaleLowerCase() or toLowerCase() to convert the string to lowercase; 2. Use toLocaleUpperCase() or toUpperCase() method to convert the string to uppercase.

How to convert string case in javascript

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

String defines 4 prototype methods to implement string case conversion operations. The description is shown in the table.

The following code converts all strings to uppercase. toLocaleLowerCase() and toLocaleUpperCase() are two localized prototype methods. They convert uppercase and lowercase letters natively, and since only a few languages ​​(such as Turkish) have local-specific case mapping, they are usually the same as the return values ​​of the toLowerCase() and toUpperCase() methods. [Recommended learning:
String String case conversion method
String method Description
toLocaleLowerCase() Convert the string to lowercase according to the local host’s locale Convert the string to uppercase
toLowerCase() Convert the string to lowercase
toUpperCase() Convert the string to uppercase
var s = "JavaScript";
console.log(s.toUpperCase());  //返回字符串“JAVASCRIPT”
Copy after login
javascript advanced tutorial

]

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template