Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 473 Bytes

File metadata and controls

40 lines (28 loc) · 473 Bytes

Check if Object is Empty

ECMA 5+:

Object.keys({}).length; // 0

Pre-ECMA 5:

function isEmpty(obj) {
    for(var prop in obj) {
        if(obj.hasOwnProperty(prop))
            return false;
    }

    return true;
}

jQuery:

jQuery.isEmptyObject({}); // true

lodash:

_.isEmpty({}); // true

Underscore:

_.isEmpty({}); // true

Source