Reputation: 195
I am trying to clone a quite complicated object with nested sub objects.
The object has a structure like this:
using jQuery.extend():
var board = $.extend(true, {}, this.game.board)
doesn't clone the nested objects, so I have used JSON to be sure there are no leftover references to the source object.
var boardJSON = JSON.stringify(JSON.decycle(this.game.board));
var board = JSON.retrocycle($.parseJSON(boardJSON));
This works very well, but the performance is miserable.
Upvotes: 1
Views: 4140