2024/07/18

LeetCode 2727. Is Object Empty

/**
 * @param {Object|Array} obj
 * @return {boolean}
 */
var isEmpty = function (obj) {
    if (obj instanceof Object)
        return !obj || Object.keys(obj).length === 0
    else if (obj instanceof Array)
        return !obj || obj.length === 0
};