I am trying to achieve the following javascript code in clojurescript:
const a = {
"foo": "bar",
//...
};
let b = {
...a,
//^ what is the clojurescript equivalent for this?
"newprop": 10,
};
I have tried to assoc-in
, thinking it would behave like a clojure map, with no success...
My question was not clear enough, I had an object defaultProps
coming from an external js library. My goal was to create a new instance of this js object and extending it with new props, and feeding it back to a js function expecting a js object. There was more to it than I first foresaw. I finally managed to do it with some juggling with js->clj
and clj->js
:
(def b
(clj->js (assoc (js->clj a) "newprop" 10)))
Thank you for your answers!