<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>js str.toLowerCase() && str.toUpperCase()</title> </head> <body> <script> /*参考:https://www.w3school.com.cn/jsref/jsref_toLowerCase.asp https://www.runoob.com/jsref/jsref-touppercase.html * 知识点: 1. * toLowerCase() 方法用于把字符串中的英文字母转换为小写。 * stringObject.toLowerCase() * 返回一个新的字符串,且不改变原始字符串。 2. toUpperCase() 方法用于把字符串中的英文字母转换为大写。 string.toUpperCase() 返回一个新的字符串,且不改变原始字符串。 */ // 一、toLowerCase() let str1 = "Hello World!"; str1 = "你好AAA!"; let str2 = str1.toLowerCase(); console.log("str1:", str1); // str1: Hello World! // str1: 你好AAA! console.log("str2:", str2); // str2: hello world! // str2: 你好aaa! // 二、toUpperCase() console.log(''); let str3 = "Runoob"; let str4 = str3.toUpperCase(); console.log("str3:", str3); // str3: Runoob console.log("str4:", str4); // str4: RUNOOB </script> </body> </html>
js str.toLowerCase() && str.toUpperCase().html
最新推荐文章于 2024-02-04 16:11:15 发布