Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this "#" mean in this Clojure context?

I stumbled upon the official Om example under "examples/mixins", there's a definition as this:

(def MyComponent (let [obj (om/specify-state-methods! (clj->js om/pure-methods))]
    (aset obj "mixins" #js [TestMixin])
    (js/React.createClass obj)))

What does "#js" mean? I couldn't find any Clojure documentation on symbol "#" when it's used in this way.

like image 487
Minos Niu Avatar asked Dec 15 '22 21:12

Minos Niu


1 Answers

From the Om tutorial:

#js {...} and #js [...] is what is referred to as a reader literal. ClojureScript supports data literals for JavaScript via #js. #js {...} is for JavaScript objects:

#js {:foo "bar"}  ;; is equivalent to
#js {"foo" "bar"}
like image 163
Diego Basch Avatar answered Dec 30 '22 13:12

Diego Basch