code: function isEmpty(obj) {
    if (Array.isArray(obj)) {
      return obj.length === 0;
    } else if (typeof obj === 'object') {
      for (var i in obj) {
        return false;
      }
      return true;
    } else {
      return !obj;
    }
  }
docs: Mimics empty from PHP.