Created
May 7, 2016 17:14
-
-
Save shakvaal/7d141398c4eda6bffff520dfd7ba8714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// функция для поверхностного (shallow) копирования полей | |
// из src в поверхностную копию dest | |
var copy = function(dest, src){ | |
var result = {}; | |
// копируем все собственные (own) поля сначала из dest в result, | |
// потом из src в result | |
[dest, src].forEach( function(obj){ | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) | |
result[key] = obj.key; | |
} | |
}); | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment