Test clone method

This commit is contained in:
Maxime Thirouin committed 2014-05-04 08:33:59 +02:00
1 parent 1a1bc03c06
commit 4404f21077
2 files changed
+29

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
module.exports = function(obj) {
if (null === obj || "object" != typeof obj) {
return obj
}
var copy = obj.constructor()
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) {
copy[attr] = obj[attr]
}
}
return copy
}