Create a copy of object, then deleted an element only from the copy, not the original : <p>How do I make <code>obj2</code> the same as <code>obj1</code> but not affected by the deletion?</p>

<p>Currently the <code>name: 42</code> entry will be deleted from both objects.</p>

<p>Is it because of hoisting - that is, the deletion occurs before <code>obj2</code> is created?</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var obj1 = {
	'name': 'John',
	'age': 42,
}

var obj2 = obj1

delete obj1['name']

console.log(obj1)
console.log(obj2)</code></pre>
</div>
</div>
</p>
