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.10.516 | Version Table

Get these docs for Dash under User Contributed downloads.


Syntax

Syntax forms, literals, conventions and patterns.

Literalsnumber literal | "" string | #"" regex | \ character | : keyword | :: keyword | symbol literal
Special Symbolstrue | false | nil
Symbolic Values##NaN | ##Inf | ##-Inf
Collections[] vector | () list | {} map | #{} set | #:{} namespaced map | #::{} namespaced map
Commenting; comment | #! shebang | #_ ignore
Function#() function | % arg | & rest
Destructuringdestructure [] | 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

Entries:main | :modules
Preloads:preloads | :browser-repl
Output:output-to | :output-dir | :asset-path | :fingerprint
Output formatting:output-wrapper | :preamble | :pretty-print | :print-input-delimiter
Optimization:optimizations | :optimize-constants | :static-fns | :fn-invoke-direct
Source map:source-map | :source-map-asset-path | :source-map-path | :source-map-timestamp
Translation:language-in | :language-out | :rewrite-polyfills
Libs:libs | :foreign-libs | :npm-deps | :install-deps | :package-json-resolution
Node.js:target | :hashbang
Externs:externs | :infer-externs | :use-only-custom-externs
Names:rename-prefix | :rename-prefix-namespace | :pseudo-names | :stable-names | :anon-fn-naming-policy
Cache analysis:cache-analysis | :cache-analysis-format
Warnings:warnings | :warning-handlers | :closure-warnings | :checked-arrays
Elide:elide-asserts | :elide-strict
Closure:closure-defines | :closure-extra-annotations | :closure-generate-exports | :closure-module-roots | :closure-output-charset | :closure-property-map-in | :closure-property-map-out | :closure-variable-map-in | :closure-variable-map-out
Spec:spec-skip-macros
Report:verbose | :compiler-stats
Watch:watch-fn | :watch-error-fn
Bootstrap:dump-core
Uncategorized:aot-cache | :ignore-js-module-exts | :opts-cache | :parallel-build | :process-shim | :recompile-dependents

REPL Options

:analyze-path | :bind-err | :caught | :compiler-env | :def-emits-var | :eval | :flush | :host | :init | :inits | :launch-browser | :need-prompt | :port | :print | :print-no-newline | :prompt | :quit-prompt | :read | :reader | :repl-requires | :repl-verbose | :source-map-inline | :src | :static-dir | :watch | :working-dir | :wrap

cljs.core

core library

Compiled*clojurescript-version* | *target*
Command Line*command-line-args* | *main-cli-fn*
Arithmetic* | + | - | / | divide | quot | rem | mod | inc | dec | identity
Min/Maxmin | max | min-key | max-key
Booleanand | or | not
Equality= | not= | == | identical? | IEquiv
Comparison< | > | <= | >= | compare | comparator | IComparable
Number sign?pos? | neg? | zero?
Integer sign?pos-int? | neg-int? | nat-int?
Integer kind?integer? | int? | odd? | even?
Double kind?number? | double? | float? | infinite?
Boolean kind?boolean? | false? | true?
Null?nil? | undefined?
Not null?some?
Any kind?any?
String kind?string? | char?
Stringstr | subs
Regexre-find | re-matches | re-pattern | re-seq | regexp?
Castboolean | char | int
Bitwisebit-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 | unsigned-bit-shift-right | int-rotate-left
REPL results*1 | *2 | *3 | *e
REPL loadrequire | require-macros | import | import-macros | use | use-macros | refer-clojure | load | load-file | load-namespace | *loaded-libs*
Exceptionstry | catch | finally | throw
Exception infoex-info | ex-message | ex-data | ex-cause
Assertassert | *assert*
Transienttransient | persistent! | conj! | pop! | assoc! | dissoc! | disj!
Volatilevolatile! | vswap! | vreset! | volatile?
Atom Refatom | swap! | reset! | compare-and-set! | swap-vals! | reset-vals! | set-validator! | get-validator
Watchadd-watch | remove-watch | IWatchable
Delay Refdelay | force | delay?
Derefderef | IDeref
Pendingrealized? | IPending
Lockinglocking
Metadatameta | with-meta | vary-meta | reset-meta! | alter-meta!
Varsdef | defonce | goog-define | declare
Var metavar | var? | exists? | resolve | set! | test
Namespacens | ns*
Namespace meta*ns* | find-ns | find-ns-obj | find-macros-ns | in-ns | create-ns | ns-imports | ns-interns | ns-interns* | ns-name | ns-publics | ns-unmap | NS_CACHE
Evaleval | *eval*
Bindingslet | let* | letfn | letfn* | binding | with-redefs
Ifif | if-not | if-some | if-let
Whenwhen | when-not | when-some | when-first | when-let
Casecase | case*
Condcond | condp
Conditional threadingcond-> | cond->> | some-> | some->>
Threading-> | ->> | as->
Wrapdo | comment | quote
Nested/Filtered loopfor | doseq
Recursionloop | loop* | recur | trampoline
Other loopswhile | dotimes
Lazylazy-seq | lazy-cat
Lazy forcingdoall | dorun | run!
Functionsdefn | defn- | fn | fn* | fn? | apply
Macrodefmacro | macroexpand | macroexpand-1 | gensym
Multimethoddefmulti | defmethod | get-method | methods | prefer-method | prefers | remove-method | remove-all-methods | default-dispatch-val | dispatch-fn
Hierarchymake-hierarchy | derive | underive | parents | ancestors | descendants | isa?
Protocoldefprotocol | extend-protocol
Typedeftype | deftype* | extend-type
Type metatype | type->str | satisfies? | instance? | implements? | is_proto_ | PROTOCOL_SENTINEL
Recorddefrecord | defrecord* | record?
Ad-hoc Instancereify | specify | specify!
Tagged Literaltagged-literal | tagged-literal?
Timingsystem-time | time | simple-benchmark
Time instanceinst-ms | inst?
Coll content?contains? | distinct? | empty? | every? | not-every? | some | not-any?
Coll capability?sequential? | associative? | sorted? | counted? | reversible? | seqable? | indexed? | iterable?
Coll typecoll? | seq? | vector? | list? | map? | set?
Coll capability interfacesISequential | IAssociative | ISorted | ICounted | IReversible | ISeqable | IIndexed | IIterable
Coll type interfacesICollection | ISeq | IVector | IList | IMap | ISet
Coll->Seqseq | cons
JS->Seqprim-seq | array-seq
Tree->Seqtree-seq
Seq->Collectionvec | set
Args->Collectionlist | list* | vector | hash-map | array-map | sorted-map | sorted-map-by | hash-set | sorted-set | sorted-set-by | obj-map
Countcount | bounded-count
Head/Tailfirst | second | next | rest | last | butlast
Head/Tail nestedffirst | nnext | nfirst | fnext
Nthnth | nthnext | nthrest
Taketake | take-nth | take-last | take-while
Dropdrop | drop-last | drop-while
Filterfilter | filterv | remove
Keepkeep | keep-indexed
Mapmap | mapv | map-indexed | mapcat | replace
Combineconcat | flatten | merge | merge-with | interleave | interpose
Duplicatesdedupe | distinct | frequencies
Partitionpartition | partition-all | partition-by
Splitsplit-at | split-with | group-by
Rearrangesort | sort-by | shuffle
Collection addconj | into | assoc | assoc-in
Collection updateupdate | update-in
Collection getget | get-in | select-keys | peek
Collection removedisj | dissoc | pop
Collection clearempty | not-empty
Map entrieskeys | vals | zipmap | key | val | find | map-entry?
Reverserseq | reverse
Subsubseq | rsubseq | subvec
Repeatcycle | repeat | replicate | iterate | range
Derive functionpartial | constantly | repeatedly | comp | complement | some-fn | every-pred | fnil | juxt | memoize
Transducetransduce | eduction | into | sequence
Transduce utilscat | halt-when | completing
Reducereduce | reduce-kv | reduced | reduced? | ensure-reduced | unreduced | reduceable? | reductions
Cloneclone | cloneable? | ICloneable
JSON<>EDNjs->clj | clj->js
JS kind?array? | object?
JS arrayarray | aget | aset | alength | amap | areduce | aclone
JS array othersmake-array | object-array | to-array | to-array-2d | into-array
JS objectjs-obj | js-keys
JS interop. | .. | doto | memfn | new
JS argumentsjs-arguments | copy-arguments
JS syntaxjs* | js-comment | js-debugger | js-delete | js-in | js-inline-comment | js-invoke | js-mod | js-reserved | js-str | this-as
Randomrand | rand-int | rand-nth | random-sample
UUIDrandom-uuid | uuid | uuid?
Name createkeyword | symbol
Name extractname | namespace
Name mungemunge | demunge | CHAR_MAP | DEMUNGE_MAP | DEMUNGE_PATTERN
Name kind?keyword? | symbol? | ident?
Name qualified?qualified-keyword? | qualified-symbol? | qualified-ident?
Name unqualified?simple-keyword? | simple-symbol? | simple-ident?
Name reserved?special-symbol?
Name identical?keyword-identical? | symbol-identical?
Machine-readable printingpr | prn
Human-readable printingprint | println
Machine-readable stringpr-str | pr-str* | pr-str-with-opts | prn-str | prn-str-with-opts
Human-readable stringprint-str | println-str
Print corestring-print | newline | with-out-str | flush
Print settings*print-dup* | *print-err-fn* | *print-fn* | *print-fn-bodies* | *print-length* | *print-level* | *print-meta* | *print-namespace-maps* | *print-newline* | *print-readably* | *flush-on-newline* | *out* | set-print-fn! | set-print-err-fn! | enable-console-print!
Tapadd-tap | remove-tap | tap> | *exec-tap-fn*
Hashinghash | hash-combine | hash-keyword | hash-string | hash-string* | hash-ordered-coll | hash-unordered-coll | mix-collection-hash | string-hash-cache | string-hash-cache-count | add-to-string-hash-cache
Uncheckedunchecked-add | unchecked-add-int | unchecked-byte | unchecked-char | unchecked-dec | unchecked-dec-int | unchecked-divide-int | unchecked-double | unchecked-float | unchecked-get | unchecked-inc | unchecked-inc-int | unchecked-int | unchecked-long | unchecked-multiply | unchecked-multiply-int | unchecked-negate | unchecked-negate-int | unchecked-remainder-int | unchecked-set | unchecked-short | unchecked-subtract | unchecked-subtract-int
Coercivecoercive-= | coercive-boolean | coercive-not | coercive-not=
MurmurHash3m3-C1 | m3-C2 | m3-fmix | m3-hash-int | m3-hash-unencoded-chars | m3-mix-H1 | m3-mix-K1 | m3-seed
ES6 Iterationes6-entries-iterator | es6-iterable | es6-iterator | es6-iterator-seq | es6-set-entries-iterator
Chunkchunk | chunk-append | chunk-buffer | chunk-cons | chunk-first | chunk-next | chunk-rest
Dummy Castbyte | short | long | float | double
Dummy Cast Manybooleans | chars | bytes | shorts | ints | longs | floats | doubles
Arraysdouble-array | long-array | int-array
Itersiter | array-iter | nil-iter | seq-iter | string-iter
Uncategorized*unchecked-arrays* | *unchecked-if* | *warn-on-infer* | MODULE_INFOS | MODULE_URIS | array-chunk | array-index-of | array-list | chunked-seq | chunked-seq? | equiv-map | gen-apply-to | gen-apply-to-simple | ifind? | ifn? | key->js | key-test | missing-protocol | mk-bound-fn | not-native | persistent-array-map-seq | pr-seq-writer | pr-sequential-writer | print-map | print-meta? | print-prefix-map | ranged-iterator | set-from-indexed-seq | spread | transformer-iterator | unsafe-cast | uri? | write-all
Types and ProtocolsAPersistentVector | ASeq | ArrayChunk | ArrayIter | ArrayList | ArrayNode | ArrayNodeIterator | ArrayNodeSeq | Atom | BitmapIndexedNode | BitmapIndexedNode.EMPTY | BlackNode | Box | ChunkBuffer | ChunkedCons | ChunkedSeq | Cons | Cycle | Delay | ES6EntriesIterator | ES6Iterator | ES6IteratorSeq | ES6SetEntriesIterator | Eduction | Empty | EmptyList | ExceptionInfo | Fn | HashCollisionNode | HashMapIter | HashSetIter | IAtom | IChunk | IChunkedNext | IChunkedSeq | IDerefWithTimeout | IEditableCollection | IEmptyableCollection | IEncodeClojure | IEncodeJS | IFind | IFn | IHash | IKVReduce | ILookup | IMapEntry | IMeta | IMultiFn | INamed | INext | IPrintWithWriter | IRecord | IReduce | IReset | IStack | ISwap | ITransientAssociative | ITransientCollection | ITransientMap | ITransientSet | ITransientVector | IUUID | IVolatile | IWithMeta | IWriter | IndexedSeq | IndexedSeqIterator | Inst | Iterate | KeySeq | Keyword | LazySeq | List | List.EMPTY | Many | MapEntry | MetaFn | MultiFn | MultiIterator | 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 | RangeChunk | RangeIterator | RangedIterator | RecordIter | RedNode | Reduced | Repeat | SeqIter | Single | StringBufferWriter | StringIter | Subvec | Symbol | TaggedLiteral | TransformerIterator | TransformerIterator.create | TransformerIterator.createMulti | 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 ProtocolsIPrettyFlush

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! | parse-and-validate-timestamp | parse-timestamp | read | read-string | register-default-tag-parser! | register-tag-parser!

cljs.repl

macros auto-imported into a ClojureScript REPL

Error->map | apropos | dir | doc | error->str | ex-str | ex-triage | find-doc | print-doc | pst | source

cljs.spec.alpha

& | * | *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 ProtocolsSpec | Specize

cljs.spec.gen.alpha

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 | shuffle | simple-type | simple-type-printable | string | string-alphanumeric | string-ascii | such-that | symbol | symbol-ns | tuple | uuid | vector | vector-distinct
Types and ProtocolsLazyVar

cljs.spec.test.alpha

->sym | abbrev-result | check | check-1 | check-fn | checkable-syms | checkable-syms* | distinct-by | enumerate-namespace | get-env | get-host-port | get-ua-product | instrument | instrument-1 | instrumentable-syms | summarize-results | unstrument | unstrument-1 | validate-check-opts | 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 ProtocolsIAsyncTest

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 ProtocolsCat | CollFold

clojure.data

non-core data functions

diff
Types and ProtocolsDiff | 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 | compiler-opts? | get-node-deps | goog-dep-string | inputs | install-node-deps! | mark-cljs-ns-for-recompile! | node-inputs | 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-env* | *repl-opts* | add-url | analyze-source | apropos | compilable? | decorate-specs | default-special-fns | demunge | dir | doc | eval-cljs | evaluate | evaluate-form | ex-str | ex-triage | file-display | find-doc | initial-prompt | js-src->cljs-src | known-repl-opts | load | load-file | load-namespace | load-stream | mapped-stacktrace | maybe-install-npm-deps | ns->input | ns-info | print-mapped-stacktrace | pst | read-source-map | repl | repl* | repl-caught | repl-nil? | repl-options | repl-prompt | repl-quit-prompt | repl-read | repl-special-doc-map | repl-title | run-inits | setup | skip-if-eol | skip-whitespace | source | source-fn | special-doc-map | tear-down
Types and ProtocolsIGetError | IJavaScriptEnv | IParseError | IParseStacktrace | IPrintStacktrace | IReplEnvOptions

cljs.repl.browser

browser-connected REPL

-main | add-in-order | browser-eval | browser-state | constrain-order | default-index | es | ext->mime-type | handle-post | load-javascript | lock | mime-type->encoding | ordering | outs | repl-client-js | repl-env | repl-env* | run-in-order | send-for-eval | send-repl-client-page | send-static | serve | setup | thread-name

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 | tear-down-engine

cljs.repl.node

Node.js REPL

-main | close-socket | create-socket | errs | load-javascript | lock | node-eval | outs | platform-path | read-response | repl-env | repl-env* | results | seq->js-array | setup | thread-name | 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 ProtocolsIEval

cljs.repl.server

connection | connq | dispatch-on | gzip | handlers | lock | parse-file-parts | parse-headers | promiseq | read-get | read-headers | read-post | read-request | send-404 | send-and-close | set-connection | start | state | stop