Created
August 5, 2019 23:41
-
-
Save neyasbltb88/f2482d101ec5f0b78ce4623a543d3701 to your computer and use it in GitHub Desktop.
Рекурсивное объединение объектов
This file contains hidden or 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
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