void 0 等于 undefined 为何不直接用undefined

缘由一: 因为undefined并非保留字 ,在ie8及ie8以前是能够直接赋值的chrome

缘由二:  在函数中若是undefined做为函数参数,则会有可能出错,像下面这样,经chrome49.0测试会出现该问题 因此谨慎一点别用undefined,函数

     不谨慎的话也别把undefined这么用。oop

var foo = function (undefined) {

    "use strict";

    var x = "foo";
    console.log(x); // "foo"
    var x = undefined;
    console.log(x); // "oops"

};

foo('oops');
相关文章
相关标签/搜索