在 JavaScript 中,我们可以使用 toUpperCase() 方法来将字符串转换为纯大写形式。
语法:
str.toUpperCase()说明:
toUpperCase() 方法不接收任何参数。
提示: toUpperCase() 方法用于将字符串转换为纯大写,而 toLowerCase() 方法用于将字符串转换为纯小写。
示例:toUpperCase() 基本用法
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
const str1 = "LvyeNet";
console.log(str1.toUpperCase());
const str2 = "LVYENET";
console.log(str2.toUpperCase());
const str3 = "lvyenet";
console.log(str3.toUpperCase());
</script>
</body>
</html>运行结果如下。
LVYENET
LVYENET
LVYENET