一般语言的字符集比如GBK,UTF-8等,包含的特殊字符集是和标准的ASCII码一致的。 但有一些特殊语言的字符集,比如土耳其语,对应的特殊字符集就跟我们的不一样,它的A不是65了,a也不是67了,用toUpperCase()就不行了,需要用toLocalUpperCase(),一般情况下使用效果是一样的。
To convert a string to uppercase, we can use the built-in method in JavaScript. Here is an example that converts a string to uppercase…
用法: string.toUpperCase() string:要转换为大写的字符串。 例子:在这里,toUpperCase()方法被调用str字符串,将所有小写字母转换为大写。得到的字符串,"HELLO WORLD", 被赋值给变量upperStr. Javascript conststr ="hello world";constupperStr = str.toUpperCase();console.log(upperStr);// Output: "HELLO WORL...
This JavaScript tutorial explains how to use the string method called toUpperCase() with syntax and examples.Description In JavaScript, toUpperCase() is a string method that is used to convert a string to uppercase. Because the toUpperCase() method is a method of the String object, it must ...
Convert to uppercase: lettext ="Hello World!"; letresult = text.toUpperCase(); Try it Yourself » Description ThetoUpperCase()method converts a string to uppercase letters. ThetoUpperCase()method does not change the original string.
console.log(uppercase_str); // HELLO WORLD! let uppercase = sentence.toUpperCase(); console.log(uppercase); // JAVA IS TO JAVASCRIPT WHAT CAR IS TO CARPET. Run Code Output HELLO WORLD! JAVA IS TO JAVASCRIPT WHAT CAR IS TO CARPET. Also Read: JavaScript String toLowerCase() JavaScrip...
In an earlier article, we looked at different ways to capitalize the first letter of a string to uppercase in JavaScript. In this article, you'll learn how to uppercase or lowercase a string using JavaScript. JavaScript provides two built-in functions for converting strings to uppercase and ...
// JavaScript to illustrate .toUpperCase()functionfunc(){// Original stringvarstr ='It iS a Great Day.';// String converted to Upper Casevarstring = str.toUpperCase();document.write(string); } func(); 输出: IT IS A GREAT DAY. 程序2: // JavaScript...
3、toLowerCase()方法用于把字符串转换为小写。 lowerString = string.toLowerCase() 4、toUpperCase()方法用于把字符串转换为大写。 upperString = string.toUpperCase() 5、toLocaleLowerCase()方法根据本地主机的语言环境把字符串转换为小写。 newString = string.toLocaleLowerCase() ...
A string is converted to upper case withtoUpperCase(): A string is converted to lower case withtoLowerCase(): JavaScript String toUpperCase() Example lettext1 ="Hello World!"; lettext2 = text1.toUpperCase(); Try it Yourself »