13 lines
248 B
JavaScript
13 lines
248 B
JavaScript
|
|
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
|
||
|
|
}
|