Skip to content

Instantly share code, notes, and snippets.

View iotch's full-sized avatar

Kanstantsin K. iotch

  • Gdansk, Poland
View GitHub Profile
@iotch
iotch / extendDeep.js
Created June 1, 2016 10:51 — forked from dalgard/extendDeep.js
Method for deep (recursive) extension of a given object with the properties of passed-in object(s) with support for standards-compliant getters and setters
function extendDeep(target) {
// Run through rest parameters
Array.prototype.slice.call(arguments, 1).forEach(function (source) {
if (typeof target === "object") {
if (typeof source === "object") {
// If source is an array, only copy enumerable properties
var keys = (Array.isArray(source) ? Object.keys(source) : Object.getOwnPropertyNames(source));
// Iterate over keys
keys.forEach(function (key) {