Nodejs Object Value Set setDefault(key, value)

Here you can find the source of setDefault(key, value)

Method Source Code

Object.prototype.setDefault = function(key, value) {
    if (!this.hasOwnProperty(key)) {
   this[key] = value;// ww w .j  ava  2 s .  c  om
    }
    return this[key];
};

Related

  1. addSibling(k, v)
    Object.prototype.addSibling = function(k, v) {
      if (typeof this[k] === 'undefined') this[k] = v;
      return this[k];