2016-01-23 76 views

回答

5

只有toUpperCase的结果是一个字符串,但toUpperCase本身是一个函数。实际上,你必须执行它,这样

console.log(typeof doh.toUpperCase()); 
// string 

例如,

console.log(typeof 'thefourtheye'.toUpperCase); 
// function 
console.log('thefourtheye'.toUpperCase); 
// [Function: toUpperCase] 
console.log(typeof 'thefourtheye'.toUpperCase()); 
// string 
console.log('thefourtheye'.toUpperCase()); 
// THEFOURTHEYE 
0

String.prototype.toUpperCase()toUpperCase()方法返回转换为大写调用字符串值。

鉴于typeof运算符返回一个指示操作数类型的字符串,所以typeof doh.toUpperCasefunction

相关问题