String.prototype.toUpperCase()
String
值的 toUpperCase()
方法返回转换为大写的字符串。
¥The toUpperCase()
method of String
values returns this string converted to uppercase.
Try it
语法
参数
返回值
描述
示例
基本用法
将非字符串 this
值转换为字符串
¥Conversion of non-string this
values to strings
当你将 this
设置为非字符串值时,此方法会将任何非字符串值转换为字符串:
¥This method will convert any non-string value to a string, when you set its
this
to a value that is not a string:
js
const a = String.prototype.toUpperCase.call({
toString() {
return "abcdef";
},
});
const b = String.prototype.toUpperCase.call(true);
// prints out 'ABCDEF TRUE'.
console.log(a, b);
规范
Specification |
---|
ECMAScript Language Specification # sec-string.prototype.touppercase |
浏览器兼容性
BCD tables only load in the browser