所以在执行传递给它的表达式后 void
返回。当您尝试访问其属性时抛出异常。那么为什么会返回而不是崩溃呢?undefined
undefined
void(0).prop
undefined
alert("void(0) => " + void(0)); // undefined
// How is it that this doesn't throw an exception?
alert("void(0).someprop => " + void(0).someprop); // undefined
// Exception, can't access property of undefined.
alert("undefined.someprop => " + undefined.someprop); // crash