function replaceValue(value, newValue, object) {

  // (1) iterate object values
  Object.entries(object).forEach(entry => {
    if (entry[ 1 ] === value) {

      // (2) replace value
      object[ entry[ 0 ] ] = newValue;
    } else if (isArray(entry[1])) {

      // (3.1) recurse
      entry[ 1 ].forEach(item => replaceValue(value, newValue, item));
    } else if (isObject(entry[ 1 ])) {

      // (3.2) recurse
      replaceValue(value, newValue, entry[ 1 ]);
    }
  });
}
/**
 * Replace all occurrences of value in object.
 *
 * @param {*} value
 * @param {*} newValue
 * @param {Object} object
 */
Replace all occurrences of value in object.


Replace all occurrences of value in object .
function replaceValue(value, newValue, object) {
  Object.entries(object).forEach(entry => {
    if (entry[ 1 ] === value) {
      object[ entry[ 0 ] ] = newValue;
    } else if (isArray(entry[1])) {
      entry[ 1 ].forEach(item => replaceValue(value, newValue, item));
    } else if (isObject(entry[ 1 ])) {
      replaceValue(value, newValue, entry[ 1 ]);
    }
  });
}
function replaceValue ( value , newValue , object ) { Object . entries ( object ) . forEach ( entry => { if ( entry [ 1 ] === value ) { object [ entry [ 0 ] ] = newValue ; } else if ( isArray ( entry [ 1 ] ) ) { entry [ 1 ] . forEach ( item => replaceValue ( value , newValue , item ) ) ; } else if ( isObject ( entry [ 1 ] ) ) { replaceValue ( value , newValue , entry [ 1 ] ) ; } } ) ; }
Replace all occurrences of value in object.
Replace all occurrences of value in object .
// (1) iterate object values
 // (2) replace value
 // (3.1) recurse
 // (3.2) recurse
