Appframe Knowledge Base

1 hits

How to recursively clone an object in JavaScript

// Used for making a copy/clone of an existing object
var firstObject = { id: "myObject", title: "test" },
	newObject = af.common.copyObject(firstObject);
// newObject will now be a clone of firstObject
// The function clones recursively, so be careful to
// not pass in objects that have a reference to them selves.

common web · Perma link post comment Posted by: Øystein Kaldestad (12-apr-2013)