Nodejs Object Key Get isEmpty()

Here you can find the source of isEmpty()

Method Source Code

Object.prototype.isEmpty = function() {
    if (this == null) return true;
    if (this.length > 0)    return false;
    if (this.length === 0)  return true;
    for (var key in this) {
        if (hasOwnProperty.call(this, key)) return false;
    }/*from   w w  w. j av a2 s. c om*/

    return true;
};

Related

  1. getKeys()
    Object.prototype.getKeys = function(){
      var keys = [];
      for (var key in this) {
        if (this.hasOwnProperty(key)) {
          keys.push(key);
      return keys
    
  2. getOwn(key, defaultValue)
    Object.prototype.getOwn = function(key, defaultValue) {
        if (this.hasOwnProperty(key)) {
      return this[key];
        else {
      return defaultValue;
    };
    
  3. hasKey(skey)
    Object.prototype.hasKey = function(skey){
      for (var key in this) {
        if (this.hasOwnProperty(key)) {
          if(key==skey){
            return true
      return false
    ...
    
  4. contains(key)
    Object.prototype.contains = function (key) {
        return this.hasOwnProperty(key);
    };
    
  5. empty()
    Object.prototype.empty = function() {
      return Object.keys(this).length <= 0;