Skip to content

Commit

Permalink
Allow cloning constructor-less objects
Browse files Browse the repository at this point in the history
  • Loading branch information
sethlu committed Sep 2, 2017
1 parent 3f5ca1c commit a362daf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function clearObject(object) {

function cloneObject(object, depth = 1) {
if (depth <= 0 || typeof object !== "object" || object === null) return object;
let clone = object.prototype.constructor();
let clone = object.constructor();
Object.keys(object).forEach(function (key) {
clone[key] = cloneObject(object[key], depth - 1);
});
Expand Down

0 comments on commit a362daf

Please sign in to comment.