-
-
Notifications
You must be signed in to change notification settings - Fork 681
Dexie.deepClone()
David Fahlander edited this page May 6, 2014
·
2 revisions
Clones an object or array completely but still lets any instance of Date or custom classes keep their prototypal structure.
var obj = {
name: "Kalle",
friends: [{name: "Olle", date: new Date(), cars: [new Car()]}]
}
var clone = Dexie.deepClone(obj);
// Now, clone will be totally "disconnected" from obj, including nestled arrays and objects.
// The date objet will still be a Date instance.
// The cars array will still be an array of Car instances.
// The following is true: ((clone.friends[0].cars[0] instanceof Car) === true)
Dexie.js - minimalistic and bullet proof indexedDB library