Object error message

Checking for an empty object in Javascript is doable, but rather interesting. See, I’m used to EXT Js having everything built in, but that isn’t always the case. For example, we have Ext.isEmpty, but in version 5, it doesn’t know any better, it basically only checks for strings and numbers (Possibly NaNs and what have you in version 6? )

function isEmptyObject( object ){
    for ( item in object ) {
        return false;
    return true;

And voila’!

This is basically a loop that checks every item stops at the first one it finds, be it a function, variable, etc.. it returns false immediately. But if it this for loop doesn’t even have ONE iteration it’ll just return true. Returning anything usually stops a function immediately.

Hope this is as useful to you as it was to me!

Happy coding!