Fork me on GitHub
#clojurescript
<
2021-03-07
>
yuhan06:03:24

Is this the idiomatic way to initalize a JS object? I tried but was unable to wrangle it into a doto form.

(let [img (js/Image.)]
  (set! (.-src img) "foo.png")
  img)

thheller08:03:39

(doto (js/Image.) (set! -src "foo.png"))

👍 2
zendevil14:03:28

when I use it, I get undefined

zendevil14:03:46

Do I have to import something and/or add a dependency?

thheller15:03:32

@ps (:require [cljs.reader :as reader]) in ns and (reader/read-string ...) after