One of the best ways to up your cljs game is to read other people’s code. When I first got started reading/writing cljs, I was confused when I saw #js.
First of all, #js is a reader literal. Reader literals are used by the cljs reader and can be used to read in a specific data type. Consider a javascript array:
You’ll see #js when doing JS interop. For example, Om provides a cljs wrapper of React, and you can see #js used to pass proper javascript objects to React:
One thing to note is that the literal only applies at the top level (i.e. won’t deeply apply to nested structures):
cljs actually includes four built-in literals: #inst, #js, #queue, and #uuid.
Now, when you see a reader literal, you’ll understand exactly what you’re looking at. If you’re interested in the implementation details, check out the source.