-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
"function () {
// Handle null or undefined or function
if (null == this || ""object"" != typeof this)
return this;
// Handle the 3 simple types, Number and String and Boolean
if(this instanceof Number || this instanceof String || this instanceof Boolean)
return this.valueOf();
// Handle Date
if (this instanceof Date) {
var copy = new Date();
copy.setTime(this.getTime());
return copy;
}
// Handle Array or Object
if (this instanceof Object || this instanceof Array) {
var copy = (this instanceof Array)?[]:{};
for (var attr in this) {
if (this.hasOwnProperty(attr))
copy[attr] = this[attr]?this[attr].clone():this[attr];
}
return copy;
}
throw new Error(""Unable to clone obj! Its type isn't supported."");
}"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels