web-interview icon indicating copy to clipboard operation
web-interview copied to clipboard

[选择题] 38.(单选题)下面代码的输出是什么

Open qiilee opened this issue 5 years ago • 0 comments

const name = "Lydia";

console.log(name());
A:SyntaxError
B: ReferenceError
C: TypeError
D: undefined

答案:C

解析:

变量 name 保存字符串的值,该字符串不是函数,因此无 法调用。

当值不是预期类型时,到抛出 TypeErrors。JavaScript 期望 name 是一个函数,因为我们试图调用它。但它是一个字符串,因此抛出 TypeError : name is not a function

qiilee avatar Apr 15 '20 02:04 qiilee