js检查对象是否为空{}


/** 是否为空对象 */
class EmptyObj {
    /**
     * @class EmptyObj
     * @method judge
     * @param {object} obj - 要传入的对象,切记不能为null
     * @return {boolean} 返回ture或者false
     * @description 判断对象是否为空{}
     * @example
     * import { emptyObj } from '../../../utils/emptyObj';
     * emptyObj.judge({name:'小明'}) //返回false
     * emptyObj.judge({}) //返回true
     */

    judge(obj) {
        return Reflect.ownKeys(obj).length === 0 && obj.constructor === Object;
    }
}
export const emptyObj = new EmptyObj();