Question: What is the most efficient way to clone a JavaScript object? I've seen `obj = eval(uneval(o));` being used, but [that's non-standard and only supported by Firefox](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval).  

 I've done things like `obj = JSON.parse(JSON.stringify(o));` but question the efficiency.   

 I've also seen recursive copying functions with various flaws.

I'm surprised no canonical solution exists.

Answer: 
I use the npm clone library. Apparently it also works in the browser.

<https://www.npmjs.com/package/clone>

```
let a = clone(b)

```
For a shallow copy there is a great, simple method introduced in ECMAScript2018 standard. It involves the use of *Spread Operator* :

```
let obj = {a : "foo", b:"bar" , c:10 , d:true , e:[1,2,3] };

let objClone = { ...obj };

```

I have tested it in Chrome browser, both objects are stored in different locations, so changing immediate child values in either will not change the other. Though (in the example) changing a value in `e` will effect both copies.

This technique is very simple and straight forward. I consider this a true Best Practice for this question once and for all.