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

How to convert lowercase letters to uppercase in javascript

青灯夜游
Release: 2021-11-26 17:18:22
Original
42189 people have browsed it

JS method to convert lowercase letters to uppercase: 1. Use toUpperCase() function, syntax "string.toUpperCase()"; 2. Use toLocaleUpperCase() function, syntax "string.toLocaleUpperCase()".

How to convert lowercase letters to uppercase in javascript

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

javascript method to convert lowercase letters to uppercase

Method 1: Use toUpperCase()

toUpperCase() method is used to convert strings to uppercase.

Syntax:

string.toUpperCase()
Copy after login

Return value: a new string in which all lowercase characters of string are converted to uppercase characters.

var str="Hello World!"
document.write(str.toUpperCase())
Copy after login

How to convert lowercase letters to uppercase in javascript

Method 2: Use toLocaleUpperCase()

toLocaleUpperCase() method is used to convert strings to uppercase.

Syntax:

string.toLocaleUpperCase()
Copy after login

Return value: a new string in which all lowercase characters of string are converted to uppercase characters.

Note: The toLocaleUpperCase() method converts the string to uppercase according to the local method. Only a few languages ​​(such as Turkish) have local case mapping, so the return value of this method is usually the same as toUpperCase().

var str="Hello World!"
console.log(str.toLocaleUpperCase());
Copy after login

How to convert lowercase letters to uppercase in javascript

【Related recommendations: javascript learning tutorial

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

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