SOURCE

function isEmpty(obj) {
    // null 和 undefined 是空对象
    if (obj === null || obj === undefined) return true;

    // 假设对象有 length 属性且 length != 0
    if (obj.length > 0) return false;
    if (obj.length === 0) return true;

    // 
    return false;
}

console.log(isEmpty(null));
console.log(isEmpty(undefined));
console.log(isEmpty({}));
console.log(_.isEmpty(11));
console 命令行工具 X clear

                    
>
console