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)

    (retweeted by a developer) How does she interpret what she has highlighted — "unlawful blocking of a public street" — as "pedestrians whose…

  • (no subject)

    Google has finally become ready to promote its Lit ecosystem properly. I thought they were going make their announcements at the coming Google IO;…

  • (no subject)

    Is it ... Bill Maher? Is he, in the penetrating eyes of this insightful lady, the emblem of white supremacy now? The comments to the tweet say it…

  • 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.