What is the most efficient way to copy JavaScript objects? What I've seen so far is
obj = eval(uneval(o));
It's like this, but it's only available on Firefox right now.
obj = JSON.parse(JSON.stringify(o));
I've seen this, but my question is the most efficient way.
// Shallow Copy
var newObject = jQuery.extend({}, oldObject);
// a deep radiation
var newObject = jQuery.extend(true, {}, oldObject);
© 2024 OneMinuteCode. All rights reserved.