index.js
function cloneDeep(value) {
  let obj = {};
  switch (typeOf(value)) {
    case 'object':
      for (let key of Object.keys(value)) {
        obj[key] = cloneDeep(value[key]);
      }
      return obj;
    case 'array':
      return value.map(ele => cloneDeep(ele));
    default: {
      return value;
    }
  }
}
function cloneDeep(value) {
  let obj = {};
  switch (typeOf(value)) {
    case 'object':
      for (let key of Object.keys(value)) {
        obj[key] = cloneDeep(value[key]);
      }
      return obj;
    case 'array':
      return value.map(ele => cloneDeep(ele));
    default: {
      return value;
    }
  }
}
function cloneDeep ( value ) { let obj = { } ; switch ( typeOf ( value ) ) { case 'object' : for ( let key of Object . keys ( value ) ) { obj [ key ] = cloneDeep ( value [ key ] ) ; } return obj ; case 'array' : return value . map ( ele => cloneDeep ( ele ) ) ; default : { return value ; } } }
Deeply clone plain objects and arrays. We're only concerned with
cloning values that are valid in JSON.
Deeply clone plain objects and arrays . We re only concerned with cloning values that are valid in JSON .