Andrey (azangru) wrote,

I've been burned by the fact that JavaScript’s native Object.assign method or Lodash's merge function mutate the first object that is passed to them more often than I would like to admit. As in:

a = { foo: 'bar' }
b = { x: 'y' }
c = Object.assign(a, b)

// c: {foo: "bar", x: "y"}
// a: {foo: "bar", x: "y"}

Ramda's merge, in contrast, being much better-behaved, does not mutate the passed objects:

a = { foo: 'bar' }
b = { x: 'y' }
c = Ramda.merge(a, b)

// c: { foo: "bar", x: "y" }
// a: { foo: "bar" }

  • (no subject)

    Imagine buying a phone that snitches on you to the authorities if it spots something illegal:

  • (no subject)

    Someone's comment on Twitter reminded me how differently we interpret what we experience: My impression from that interview was that Yuri was…

  • (no subject)

    Via Twitter. From the book The Gray Lady Winked, photographed by Michael Shermer: Here's the tweet that the paragraph references (took a while…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.