function/macro | since v0.0-927 | clojure.core/instance? | Edit |
(instance? c x)
Returns true if x
is an instance of type c
, false otherwise.
Evaluates x and tests if it is an instance of the type c. Returns true or false
(defn ^boolean instance?
[c x]
(cljs.core/instance? c x))
(core/defmacro instance? [c x]
;; Google Closure warns about some references to RegExp, so
;; (instance? RegExp ...) needs to be inlined, but the expansion
;; should preserve the order of argument evaluation.
(bool-expr (if (clojure.core/symbol? c)
(core/list 'js* "(~{} instanceof ~{})" x c)
`(let [c# ~c x# ~x]
(~'js* "(~{} instanceof ~{})" x# c#)))))