ClojureScript API

Welcome! This is a comprehensive reference for ClojureScript's syntax, standard library, and compiler API. See the Cheatsheet for quick reference

Documentation is versioned and supplemented by curated descriptions,examples, and cross-refs. Community contributions welcome.

Current Version: 1.9.495+ (master) | Version Table

Get these docs for Dash under User Contributed downloads.


Syntax

Literals: number literal | "" string | #"" regex | \ character | : keyword | :: keyword | symbol literal
Special Symbols: true | false | nil | NaN | Infinity
Collections: [] vector | () list | {} map | #{} set | #:{} namespaced map | #::{} namespaced map
Commenting: ; comment | #! shebang | #_ ignore
Function: #() function | % arg | & rest
Destructuring: destructure [] | destructure {}
Conventions: ? predicate | ! impure | *earmuffs* | _ unused | whitespace | , comma
Symbol Resolution: . dot | / namespace slash | js/ namespace | Math/ namespace
Tagged Literals: # tagged literal | #js literal | #inst literal | #uuid literal | #queue literal
Quoting: ' quote | ` syntax quote | ~ unquote | ~@ unquote splicing | # auto-gensym
Vars: ^ meta | #' var | @ deref
Reader Conditionals: #? reader conditional | #?@ reader conditional splicing
Misc: # dispatch | #<> unreadable | #= eval

Compiler Options

:anon-fn-naming-policy | :asset-path | :browser-repl | :cache-analysis | :cache-analysis-format | :closure-defines | :closure-extra-annotations | :closure-generate-exports | :closure-warnings | :compiler-stats | :dump-core | :elide-asserts | :emit-constants | :externs | :foreign-libs | :hashbang | :infer-externs | :language-in | :language-out | :libs | :main | :modules | :optimizations | :optimize-constants | :output-dir | :output-to | :output-wrapper | :parallel-build | :preamble | :preloads | :pretty-print | :print-input-delimiter | :pseudo-names | :recompile-dependents | :source-map | :source-map-asset-path | :source-map-path | :source-map-timestamp | :static-fns | :target | :ups-externs | :ups-foreign-libs | :ups-libs | :use-only-custom-externs | :verbose | :warning-handlers | :warnings | :watch-error-fn | :watch-fn

REPL Options

:analyze-path | :bind-err | :caught | :compiler-env | :def-emits-var | :eval | :flush | :init | :need-prompt | :print | :print-no-newline | :prompt | :quit-prompt | :read | :reader | :repl-requires | :repl-verbose | :source-map-inline | :watch | :wrap

Namespaces

cljs.core

core library

* | *1 | *2 | *3 | *assert* | *clojurescript-version* | *e | *flush-on-newline* | *loaded-libs* | *main-cli-fn* | *ns* | *out* | *print-dup* | *print-err-fn* | *print-fn* | *print-length* | *print-level* | *print-meta* | *print-namespace-maps* | *print-newline* | *print-readably* | *target* | *unchecked-if* | *warn-on-infer* | + | - | -> | ->> | . | .. | / | < | <= | = | == | > | >= | CHAR_MAP | DEMUNGE_MAP | DEMUNGE_PATTERN | NS_CACHE | PROTOCOL_SENTINEL | aclone | add-to-string-hash-cache | add-watch | aget | alength | alter-meta! | amap | ancestors | and | any? | apply | areduce | array | array-chunk | array-index-of | array-iter | array-list | array-map | array-seq | array? | as-> | aset | assert | assoc | assoc! | assoc-in | associative? | atom | binding | bit-and | bit-and-not | bit-clear | bit-count | bit-flip | bit-not | bit-or | bit-set | bit-shift-left | bit-shift-right | bit-shift-right-zero-fill | bit-test | bit-xor | boolean | boolean? | booleans | bounded-count | butlast | byte | bytes | case | case* | cat | catch | char | char? | chars | chunk | chunk-append | chunk-buffer | chunk-cons | chunk-first | chunk-next | chunk-rest | chunked-seq | chunked-seq? | clj->js | clone | cloneable? | coercive-= | coercive-boolean | coercive-not | coercive-not= | coll? | comment | comp | comparator | compare | compare-and-set! | complement | completing | concat | cond | cond-> | cond->> | condp | conj | conj! | cons | constantly | contains? | copy-arguments | count | counted? | create-ns | cycle | dec | declare | dedupe | def | default-dispatch-val | defmacro | defmethod | defmulti | defn | defn- | defonce | defprotocol | defrecord | defrecord* | deftype | deftype* | delay | delay? | demunge | deref | derive | descendants | disj | disj! | dispatch-fn | dissoc | dissoc! | distinct | distinct? | divide | do | doall | dorun | doseq | dotimes | doto | double | double-array | double? | doubles | drop | drop-last | drop-while | eduction | empty | empty? | enable-console-print! | ensure-reduced | es6-entries-iterator | es6-iterable | es6-iterator | es6-iterator-seq | es6-set-entries-iterator | even? | every-pred | every? | ex-cause | ex-data | ex-info | ex-message | exists? | extend-protocol | extend-type | false? | ffirst | filter | filterv | finally | find | find-macros-ns | find-ns | find-ns-obj | first | flatten | float | float? | floats | flush | fn | fn* | fn? | fnext | fnil | for | force | frequencies | gen-apply-to | gensym | get | get-in | get-method | get-validator | goog-define | group-by | halt-when | hash | hash-combine | hash-keyword | hash-map | hash-ordered-coll | hash-set | hash-string | hash-string* | hash-unordered-coll | ident? | identical? | identity | if | if-let | if-not | if-some | ifn? | implements? | import | import-macros | in-ns | inc | indexed? | infinite? | inst-ms | inst? | instance? | int | int-array | int-rotate-left | int? | integer? | interleave | interpose | into | into-array | ints | is_proto_ | isa? | iter | iterable? | iterate | js* | js->clj | js-arguments | js-comment | js-debugger | js-delete | js-in | js-inline-comment | js-invoke | js-keys | js-mod | js-obj | js-reserved | js-str | juxt | keep | keep-indexed | key | key->js | key-test | keys | keyword | keyword-identical? | keyword? | last | lazy-cat | lazy-seq | lazy-transformer | let | let* | letfn | letfn* | list | list* | list? | load | load-file | load-namespace | locking | long | long-array | longs | loop | loop* | m3-C1 | m3-C2 | m3-fmix | m3-hash-int | m3-hash-unencoded-chars | m3-mix-H1 | m3-mix-K1 | m3-seed | macroexpand | macroexpand-1 | make-array | make-hierarchy | map | map-indexed | map? | mapcat | mapv | max | max-key | memfn | memoize | merge | merge-with | meta | methods | min | min-key | missing-protocol | mix-collection-hash | mk-bound-fn | mod | multi-stepper | munge | name | namespace | nat-int? | neg-int? | neg? | new | newline | next | nfirst | nil-iter | nil? | nnext | not | not-any? | not-empty | not-every? | not-native | not= | ns | ns* | ns-interns | ns-interns* | ns-name | ns-unmap | nth | nthnext | nthrest | number? | obj-map | object-array | object? | odd? | or | parents | partial | partition | partition-all | partition-by | peek | persistent! | persistent-array-map-seq | pop | pop! | pos-int? | pos? | pr | pr-seq-writer | pr-sequential-writer | pr-str | pr-str* | pr-str-with-opts | prefer-method | prefers | prim-seq | print | print-map | print-meta? | print-prefix-map | print-str | println | println-str | prn | prn-str | prn-str-with-opts | qualified-ident? | qualified-keyword? | qualified-symbol? | quot | quote | rand | rand-int | rand-nth | random-sample | random-uuid | range | ranged-iterator | re-find | re-matches | re-pattern | re-seq | realized? | record? | recur | reduce | reduce-kv | reduceable? | reduced | reduced? | reductions | refer-clojure | regexp? | reify | rem | remove | remove-all-methods | remove-method | remove-watch | repeat | repeatedly | replace | replicate | require | require-macros | reset! | reset-meta! | rest | reverse | reversible? | rseq | rsubseq | run! | satisfies? | second | select-keys | seq | seq-iter | seq? | seqable? | sequence | sequential? | set | set! | set-from-indexed-seq | set-print-err-fn! | set-print-fn! | set-validator! | set? | short | shorts | shuffle | simple-benchmark | simple-ident? | simple-keyword? | simple-symbol? | some | some-> | some->> | some-fn | some? | sort | sort-by | sorted-map | sorted-map-by | sorted-set | sorted-set-by | sorted? | special-symbol? | specify | specify! | split-at | split-with | spread | stepper | str | string-hash-cache | string-hash-cache-count | string-iter | string-print | string? | subs | subseq | subvec | swap! | symbol | symbol-identical? | symbol? | system-time | tagged-literal | tagged-literal? | take | take-last | take-nth | take-while | test | this-as | throw | time | to-array | to-array-2d | trampoline | transduce | transient | tree-seq | true? | try | type | type->str | unchecked-add | unchecked-add-int | unchecked-byte | unchecked-char | unchecked-dec | unchecked-dec-int | unchecked-divide-int | unchecked-double | unchecked-float | unchecked-inc | unchecked-inc-int | unchecked-int | unchecked-long | unchecked-multiply | unchecked-multiply-int | unchecked-negate | unchecked-negate-int | unchecked-remainder-int | unchecked-short | unchecked-subtract | unchecked-subtract-int | undefined? | underive | unreduced | unsafe-cast | unsigned-bit-shift-right | update | update-in | use | use-macros | uuid | uuid? | val | vals | var | var? | vary-meta | vec | vector | vector? | volatile! | volatile? | vreset! | vswap! | when | when-first | when-let | when-not | when-some | while | with-meta | with-out-str | with-redefs | write-all | zero? | zipmap
Types and Protocols: ASeq | ArrayChunk | ArrayIter | ArrayList | ArrayNode | ArrayNodeIterator | ArrayNodeSeq | Atom | BitmapIndexedNode | BitmapIndexedNode.EMPTY | BlackNode | Box | ChunkBuffer | ChunkedCons | ChunkedSeq | Cons | Delay | ES6EntriesIterator | ES6Iterator | ES6IteratorSeq | ES6SetEntriesIterator | Eduction | EmptyList | ExceptionInfo | Fn | HashCollisionNode | HashMapIter | HashSetIter | IAssociative | IAtom | IChunk | IChunkedNext | IChunkedSeq | ICloneable | ICollection | IComparable | ICounted | IDeref | IDerefWithTimeout | IEditableCollection | IEmptyableCollection | IEncodeClojure | IEncodeJS | IEquiv | IFn | IHash | IIndexed | IIterable | IKVReduce | IList | ILookup | IMap | IMapEntry | IMeta | IMultiFn | INamed | INext | IPending | IPrintWithWriter | IRecord | IReduce | IReset | IReversible | ISeq | ISeqable | ISequential | ISet | ISorted | IStack | ISwap | ITransientAssociative | ITransientCollection | ITransientMap | ITransientSet | ITransientVector | IUUID | IVector | IVolatile | IWatchable | IWithMeta | IWriter | IndexedSeq | IndexedSeqIterator | Inst | KeySeq | Keyword | LazySeq | LazyTransformer | LazyTransformer.create | LazyTransformer.createMulti | List | List.EMPTY | MetaFn | MultiFn | MultiStepper | Namespace | NeverEquiv | NodeIterator | NodeSeq | ObjMap | ObjMap.EMPTY | ObjMap.HASHMAP_THRESHOLD | ObjMap.fromObject | PersistentArrayMap | PersistentArrayMap.EMPTY | PersistentArrayMap.HASHMAP-THRESHOLD | PersistentArrayMap.createAsIfByAssoc | PersistentArrayMap.createWithCheck | PersistentArrayMap.fromArray | PersistentArrayMapIterator | PersistentArrayMapSeq | PersistentHashMap | PersistentHashMap.EMPTY | PersistentHashMap.createWithCheck | PersistentHashMap.fromArray | PersistentHashMap.fromArrays | PersistentHashSet | PersistentHashSet.EMPTY | PersistentHashSet.createAsIfByAssoc | PersistentHashSet.createWithCheck | PersistentHashSet.fromArray | PersistentQueue | PersistentQueue.EMPTY | PersistentQueueIter | PersistentQueueSeq | PersistentTreeMap | PersistentTreeMap.EMPTY | PersistentTreeMapSeq | PersistentTreeSet | PersistentTreeSet.EMPTY | PersistentVector | PersistentVector.EMPTY | PersistentVector.EMPTY-NODE | PersistentVector.fromArray | RSeq | Range | RangeIterator | RangedIterator | RecordIter | RedNode | Reduced | SeqIter | Stepper | StringBufferWriter | StringIter | Subvec | Symbol | TaggedLiteral | TransientArrayMap | TransientHashMap | TransientHashSet | TransientVector | UUID | ValSeq | Var | VectorNode | Volatile

cljs.js

compile/analyze ClojureScript code at runtime.

*eval-fn* | *load-fn* | *loaded* | analyze-str | compile-str | dump-core | empty-state | eval | eval-str | file->ns | js-eval | load-analysis-cache! | load-source-map! | ns->relpath | require | with-state

cljs.nodejs

nodejs support functions

enable-util-print! | process | require

cljs.pprint

a pretty-printer for printing data structures

*print-base* | *print-miser-width* | *print-pprint-dispatch* | *print-pretty* | *print-radix* | *print-right-margin* | *print-suppress-namespaces* | char-code | cl-format | code-dispatch | deftype | float? | formatter | formatter-out | fresh-line | get-pretty-writer | getf | pp | pprint | pprint-indent | pprint-logical-block | pprint-newline | pprint-set | pprint-tab | print-length-loop | print-table | set-pprint-dispatch | setf | simple-dispatch | with-pprint-dispatch | with-pretty-writer | write | write-out
Types and Protocols: IPrettyFlush

cljs.reader

a reader to parse text and produce data structures

*default-data-reader-fn* | *tag-table* | add-data-readers | deregister-default-tag-parser! | deregister-tag-parser! | desugar-meta | dispatch-macros | escape-char | escape-char-map | float-pattern | int-pattern | macro-terminating? | macros | make-unicode-char | maybe-read-tagged-type | not-implemented | parse-and-validate-timestamp | parse-timestamp | push-back-reader | ratio-pattern | read | read-2-chars | read-4-chars | read-comment | read-delimited-list | read-discard | read-dispatch | read-keyword | read-list | read-literal | read-map | read-meta | read-number | read-past | read-raw-string* | read-regex | read-set | read-string | read-string* | read-symbol | read-token | read-unmatched-delimiter | read-vector | reader-error | register-default-tag-parser! | register-tag-parser! | skip-line | special-symbols | symbol-pattern | throwing-reader | unicode-2-pattern | unicode-4-pattern | validate-unicode-escape | wrapping-reader
Types and Protocols: PushbackReader | StringPushbackReader

cljs.repl

macros auto-imported into a ClojureScript REPL

apropos | dir | doc | err-out | find-doc | print-doc | pst | source

cljs.spec

& | * | *coll-check-limit* | *coll-error-limit* | *compile-asserts* | *explain-out* | *fspec-iterations* | *recursion-limit* | + | ? | MAX_INT | abbrev | alt | and | assert | assert* | cat | check-asserts | check-asserts? | coll-of | conform | conformer | def | describe | double-in | every | every-kv | exercise | exercise-fn | explain | explain-data | explain-data* | explain-out | explain-printer | explain-str | fdef | form | fspec | gen | get-spec | inst-in | inst-in-range? | int-in | int-in-range? | invalid? | keys | keys* | map-of | merge | multi-spec | nilable | nonconforming | or | regex? | registry | registry-ref | spec | spec? | speced-vars | tuple | unform | valid? | with-gen
Types and Protocols: Spec | Specize

cljs.spec.impl.gen

any | any-printable | bind | boolean | cat | char | char-alpha | char-alphanumeric | char-ascii | choose | delay | double | double* | dynaload | elements | fmap | for-all* | frequency | gen-for-pred | generate | hash-map | int | keyword | keyword-ns | large-integer | large-integer* | list | map | not-empty | one-of | quick-check | ratio | return | sample | set | simple-type | simple-type-printable | string | string-alphanumeric | string-ascii | such-that | symbol | symbol-ns | tuple | uuid | vector | vector-distinct
Types and Protocols: LazyVar

cljs.spec.test

->sym | abbrev-result | check | check-1 | check-fn | checkable-syms | checkable-syms* | distinct-by | get-env | get-host-port | get-ua-product | instrument | instrument-1 | instrumentable-syms | summarize-results | unstrument | unstrument-1 | with-instrument-disabled

cljs.test

a unit-testing framework

*current-env* | are | assert-any | assert-expr | assert-predicate | async | async? | block | clear-env! | compose-fixtures | deftest | do-report | empty-env | file-and-line | function? | get-and-clear-env! | get-current-env | inc-report-counter! | is | join-fixtures | js-filename | js-line-and-column | mapped-line-and-column | ns? | report | run-all-tests | run-block | run-tests | run-tests-block | set-env! | successful? | test-all-vars | test-all-vars-block | test-ns | test-ns-block | test-var | test-var-block | test-vars | test-vars-block | testing | testing-contexts-str | testing-vars-str | try-expr | update-current-env! | use-fixtures
Types and Protocols: IAsyncTest

clojure.core.reducers

a library for reduction and parallel folding (parallelism not supported)

append! | cat | drop | filter | flatten | fold | foldcat | folder | map | mapcat | monoid | reduce | reducer | remove | take | take-while
Types and Protocols: Cat | CollFold

clojure.data

non-core data functions

diff
Types and Protocols: Diff | EqualityPartition

clojure.reflect

deprecated

doc | macroexpand | meta | print-doc

clojure.set

set operations such as union/intersection

difference | index | intersection | join | map-invert | project | rename | rename-keys | select | subset? | superset? | union

clojure.string

string operations

blank? | capitalize | ends-with? | escape | includes? | index-of | join | last-index-of | lower-case | replace | replace-first | reverse | split | split-lines | starts-with? | trim | trim-newline | triml | trimr | upper-case

clojure.walk

a generic tree walker for Clojure data structures

keywordize-keys | postwalk | postwalk-replace | prewalk | prewalk-replace | stringify-keys | walk

clojure.zip

functional hierarchical zipper, w/ navigation/editing/enumeration

append-child | branch? | children | down | edit | end? | insert-child | insert-left | insert-right | left | leftmost | lefts | make-node | next | node | path | prev | remove | replace | right | rightmost | rights | root | seq-zip | up | vector-zip | xml-zip | zipper

Compiler

cljs.analyzer.api

programmatic access to the analyzer (producing AST)

all-ns | analyze | analyze-file | default-warning-handler | empty-env | empty-state | find-ns | forms-seq | get-js-index | get-options | in-cljs-user | no-warn | ns-interns | ns-publics | ns-resolve | parse-ns | remove-ns | resolve | warning-enabled? | with-state

cljs.build.api

programmatic access to project-building facilities

add-dependencies | add-implicit-options | build | cljs-dependents-for-macro-namespaces | compile | goog-dep-string | inputs | mark-cljs-ns-for-recompile! | node-inputs | node-module-deps | ns->location | ns->source | output-unoptimized | parse-js-ns | source-on-disk | src-file->goog-require | src-file->target-file | target-file-for-cljs-ns | watch

cljs.compiler.api

programmatic access to the compiler (emitting JS)

cljs-files-in | compile-file | compile-root | emit | requires-compilation? | with-core-cljs

cljs.repl

macros auto-imported into a ClojureScript REPL

*cljs-verbose* | *repl-opts* | analyze-source | apropos | decorate-specs | default-special-fns | dir | doc | err-out | evaluate-form | find-doc | js-src->cljs-src | known-repl-opts | load-file | load-namespace | load-stream | mapped-stacktrace | ns-info | print-mapped-stacktrace | pst | read-source-map | repl | repl* | repl-caught | repl-prompt | repl-quit-prompt | repl-read | repl-special-doc-map | skip-if-eol | skip-whitespace | source | source-fn | special-doc-map
Types and Protocols: IGetError | IJavaScriptEnv | IParseError | IParseStacktrace | IPrintStacktrace | IReplEnvOptions

cljs.repl.browser

browser-connected REPL

-main | add-in-order | browser-eval | browser-state | compile-client-js | constrain-order | create-client-js-file | es | ext->mime-type | handle-post | load-javascript | mime-type->encoding | ordering | repl-client-js | repl-env | repl-env* | run-in-order | send-for-eval | send-repl-client-page | send-static | setup

cljs.repl.nashorn

Nashorn REPL (JS on Java 8)

-main | bootstrap-repl | create-engine | eval-resource | eval-str | init-engine | load-js-file | load-ns | repl-env | repl-env* | repl-filename

cljs.repl.node

Node.js REPL

-main | close-socket | load-javascript | node-eval | platform-path | read-response | repl-env | repl-env* | seq->js-array | setup | socket | write

cljs.repl.reflect

handle-reflect-query | macroexpand | parse-param | read-url-string

cljs.repl.rhino

Rhino REPL (JS on Java 6+)

-main | bootjs | eval-result | load-file | load-javascript | repl-env | repl-env* | rhino-eval | rhino-setup | stacktrace | wrap-fn
Types and Protocols: IEval

cljs.repl.server

connection | dispatch-on | handlers | parse-headers | read-get | read-headers | read-post | read-request | send-404 | send-and-close | set-connection | start | state | stop