Skip to content

Instantly share code, notes, and snippets.

View JamesGelok's full-sized avatar
:shipit:

James JamesGelok

:shipit:
View GitHub Profile
@JamesGelok
JamesGelok / extendDeep.js
Created August 4, 2021 17:11 — 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) {