标签: javascript
为什么在执行这段代码时,只检查thisThrowsError实际上是否会抛出错误,但查询原型对象或this上下文中不存在的属性不会?
thisThrowsError
this
function Test() { if(this.someVar){} if(Test.prototype.someVar){} if(thisThrowsError){} } var test = new Test();
答案 0 :(得分:0)
请参阅:Why does an undefined variable in Javascript sometimes evaluate to false and sometimes throw an uncaught ReferenceError?