首页 > 代码库 > js 中比较 undefined

js 中比较 undefined

// x has not been declared beforeif (typeof x === ‘undefined‘) { // evaluates to true without errors   // these statements execute}//如果未定义变量,那么会出现引用错误if(x === undefined){ // throws a ReferenceError}

js 中比较 undefined