窗口对象不存在但仍存在于NodeJS中

jim*_*mmy 3 node.js

if(typeof window !== undefined) {
  console.log("this should print only if window object actually exists")
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我为什么在检查窗口是否未定义时NodeJS(0.6.5)无法正常工作?如果你调用typeof window,你会得到未定义但仍然无法正常工作.有任何想法吗?

Dam*_*amp 8

if(typeof window !== 'undefined') {
  console.log("this should print only if window object actually exists")
}
Run Code Online (Sandbox Code Playgroud)

typeof返回一个字符串