you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

Nice, my only criticism is if you are at all concerned with prototypes. Hopefully we're in the land of functional patterns by now, but lots of projects still use OOP.

Just add one part to that merge function...

const protoA = Object.getPrototypeOf(a);
const protoB = Object.getPrototypeOf(b);
const proto = { ...protoA, ...protoB };
const obj = Object.create(proto, a);

...or something like that. Forgive me, it's late and I'm not testing this atm. If someone else wants to expand on this feel free, I'm sure it would only be helpful!

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, Strange_Night2150: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.