Appropriate way to create immutable objects in nodejs
<p>I'm building an API, where I wish to make my final <strong>returning</strong> <code>object</code> an <strong>immutable object</strong>. Make the only way to change my object is to copy to another instance.</p>

<p>How Can I do that?</p>

<h2>Expected behavior:</h2>

<pre><code>var objectImmutable = api.call(id);
objectImmutable.new_var = 10;
console.log(objectImmutable.new_var)
=&gt;undefined
//---------
var objectNotImmutable =  JSON.parse(JSON.stringify(api.call(id)));
objectNotImmutable .new_var = 10;
console.log(objectImmutable.new_var)
=&gt;10
</code></pre>