JSFiddle - React, Tailwind, and code Playground
by Julien Etienne
JavaScript
const aquire = (target, ...sources) => {
const sourcesLength = sources.length;
for (let i = 0; i < sourcesLength; i++) {
const source = sources[i];
if (typeof source === 'object' || typeof source === 'string') {
const keys = Object.keys(source);
const keysLength = keys.length;
for (let j = 0; j < keysLength; j++) {
const key = keys[j];
target[key] = source[key];
}
} else {
return target;
}
}
return target;
}
const a = {
a: 1,
b: 2,
c: 3
}
const b = {
d: 4,
e: 5,
f: 6
}
const c = {
g: 7,
h: 8,
i: 9
}
const results = aquire(a, b, c,'hello');
console.log(results)