cljs-bootstrap

cljs-bootstrap Web REPL

 

ClojureScript at a glance - PDF | Searchable docs

Datatypes

Map {:key1 :val1, :key2 :val2}
Vectors [1 2 3 4 :a :b :c 1 2]
Sets #{:a :b :c 1 2 3}
Scalars a-symbol, :a-keyword, "a string"
Arrays (array 1 2 3)

Functions

Calling (<function> <args*>)
Defining named functions (defn <name> [<args*>] |constraints| <actions*>)
Anonymous function (fn |name| [<args*>] |constraints| <actions*>)
Anonymous inline function #(<action> |%,%2,%3, or %&|)

Useful Macros

Conditionals if if-let cond condp and or when when-let
Nesting, chaining, and Interop -> ->> doto .. .
Defining things def defn fn let binding defmulti defmethod deftype defrecord reify this-as

Useful Functions

Math + - * / quot rem mod inc dec max min
Comparison = == not= < > <= >=
Predicates nil? identical? zero? pos? neg? even? odd? true? false?
Data processing map reduce filter partition split-at split-with
Data create vector vec hash-map set for list list*
Data inspection first rest get get-in keys vals count get nth contains? find
Data manipulation seq into conj cons assoc assoc-in dissoc zipmap merge merge-with select-keys update-in
Arrays first rest get get-in keys vals count get nth contains? find

JavaScript Interop

Method call (.the-method target-object args...)
Property access (.-property target-object -property)
Property setting (set! (.-title js/document) "Hi!")
Direct JavaScript (js/alert "Hello Cleveland!")
External library use (.text (js/jQuery "#title") "ClojureScript Rocks!")