JSFiddle - React, Tailwind, and code Playground

by Julien Etienne

JavaScript

const {
  parse,
/*   stringify */
} = JSON;

const _store = {
  El: {
    leftSidebar: null, // This is an optional placeholder name for the leftSidebar.
    articles: { // Namespace
      articleOne: null, // Optional placeholder names
      articleTwo: null // Optional placeholder names
    },
    body: document.body
  }
}

const store = {};

const cloneObject = (toCopy) => {
    const toRead = JSON.stringify(toCopy)
	  const object = {};
    for(let i = 0; i < toRead.length; i++){
        const property = toRead[i];
        if(property !== null && typeof property === 'object') {
          object[property] = toRead[property];
        } else {
        
        }
    }
    for(let i in obj) {
        if(obj[i] !== null && typeof(obj[i]) === "object"){
          store[i] = cloneObject(obj[i]);
        } else{
          store[i] = obj[i];
        }
   }
    return store;
}

console.log(
	cloneObject(_store, store)
);