Setting one object equal to another object with the assignment operator in Javascript

Whenever I need to copy one object to another in JS, I just cast it to a primitive:

var newObject = JSON.stringify(oldObject);

Then when I need to use it:

var evenNewerObj = JSON.parse(newObject);

Hope this helps someone.

Leave a Comment