Skip to content

Instantly share code, notes, and snippets.

@neyasbltb88
Created August 5, 2019 23:41
Show Gist options
  • Save neyasbltb88/f2482d101ec5f0b78ce4623a543d3701 to your computer and use it in GitHub Desktop.
Save neyasbltb88/f2482d101ec5f0b78ce4623a543d3701 to your computer and use it in GitHub Desktop.
Рекурсивное объединение объектов
function _extend(to, from) {
var i;
var toStr = Object.prototype.toString;
var astr = '[object Array]';
to = to || {};
for (i in from) {
if (from.hasOwnProperty(i)) {
if (typeof from[i] === 'object') {
to[i] = (toStr.call(from[i]) === astr) ? [] : {};
namespace.ya.speechkit._extend(to[i], from[i]);
} else if (typeof from[i] !== 'undefined' || typeof to[i] === 'undefined') {
to[i] = from[i];
}
}
}
return to;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment