Detecting an undefined object property

后端 未结 30 2817
花落未央
花落未央 2020-11-21 04:43

What\'s the best way of checking if an object property in JavaScript is undefined?

30条回答
  •  囚心锁ツ
    2020-11-21 05:41

    In the article Exploring the Abyss of Null and Undefined in JavaScript I read that frameworks like Underscore.js use this function:

    function isUndefined(obj){
        return obj === void 0;
    }
    

提交回复
热议问题