Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么在执行这段代码时,只检查thisThrowsError实际会抛出错误,而在原型对象或上下文中查询不存在的属性this却不会?
thisThrowsError
this
function Test() { if(this.someVar){} if(Test.prototype.someVar){} if(thisThrowsError){} } var test = new Test();
请参阅:为什么 Javascript 中的未定义变量有时会评估为 false,有时会抛出未捕获的 ReferenceError?