clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
yuhan 2021-03-07T06:39:24.238300Z

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)

thheller 2021-03-07T08:34:39.238700Z

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

👍 2
zendevil 2021-03-07T14:25:06.239700Z

I saw this link with cljs.reader https://cljs.github.io/api/cljs.reader/read-string

zendevil 2021-03-07T14:25:28.240500Z

when I use it, I get undefined

zendevil 2021-03-07T14:25:46.241Z

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

thheller 2021-03-07T15:49:32.241600Z

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

zendevil 2021-03-07T16:27:39.241900Z

thanks @thheller