daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Feb 18th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const deepClone = (obj, cloned = {}) => {
  2.   for(const key of Object.keys(obj)){
  3.     const value = obj[key];
  4.     if(isObject(value)) {
  5.       cloned[key] = {};
  6.       deepClone(value, cloned[key]);
  7.     } else if(Array.isArray(value)) {
  8.       cloned[key] = [].slice.call(value, 0);
  9.     } else {
  10.       cloned[key] = obj[key];
  11.     }
  12.   }
  13.  
  14.   return cloned;
  15. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top