November 14, 2017 · clojurescript frontend

Two ways to set and get property in clojurescript

There's two forms to get and set property in clojurescript.

;; get property
(.-innerHTML el)
(aget el "innerHTML")

;; set property	
(set! (.-innerHTML el) "Hi!")
(aset el "innerHTML" "Hi!")

In practice, use aget with aset or set! with .-attr form, but don't mix them. Otherwise closure name mangling may cause problem, in minified code.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket