 (defn ^String emit-str [expr]
   (with-out-str (emit expr)))
 
-(defmulti emit-constant class)
+#?(:clj
+   (defmulti emit-constant class)
+   :cljs
+   (defmulti emit-constant type))
+
 (defmethod emit-constant nil [x] (emits "null"))
-(defmethod emit-constant Long [x] (emits "(" x ")"))
-(defmethod emit-constant Integer [x] (emits x)) ; reader puts Integers in metadata
-(defmethod emit-constant Double [x] (emits x))
-(defmethod emit-constant BigDecimal [x] (emits (.doubleValue ^BigDecimal x)))
-(defmethod emit-constant clojure.lang.BigInt [x] (emits (.doubleValue ^clojure.lang.BigInt x)))
+
+#?(:clj
+   (defmethod emit-constant Long [x] (emits "(" x ")")))
+
+#?(:clj
+   (defmethod emit-constant Integer [x] (emits x))) ; reader puts Integers in metadata
+
+#?(:clj
+   (defmethod emit-constant Double [x] (emits x))
+   :cljs
+   (defmethod emit-constant Number [x] (emits x)))
+
+#?(:clj
+   (defmethod emit-constant BigDecimal [x] (emits (.doubleValue ^BigDecimal x))))
+
+#?(:clj
+   (defmethod emit-constant clojure.lang.BigInt [x] (emits (.doubleValue ^clojure.lang.BigInt x))))
+
 (defmethod emit-constant String [x]
   (emits (wrap-in-double-quotes (escape-string x))))
+
 (defmethod emit-constant Boolean [x] (emits (if x "true" "false")))
-(defmethod emit-constant Character [x]
-  (emits (wrap-in-double-quotes (escape-char x))))
-
-(defmethod emit-constant java.util.regex.Pattern [x]
+
+#?(:clj
+   (defmethod emit-constant Character [x]
+     (emits (wrap-in-double-quotes (escape-char x)))))
+
+(defmethod emit-constant #?(:clj java.util.regex.Pattern :cljs js/RegExp) [x]
   (if (= "" (str x))
     (emits "(new RegExp(\"\"))")
     (let [[_ flags pattern] (re-find #"^(?:\(\?([idmsux]*)\))?(.*)" (str x))]

    (emit-constant (hash kw))
    (emits ")")))

(defmethod emit-constant clojure.lang.Keyword [x]
  (if (-> @env/*compiler* :options :emit-constants)
    (let [value (-> @env/*compiler* ::ana/constant-table x)]
      (emits "cljs.core." value))
    (emits-keyword x)
    ))

(defmethod emit-constant clojure.lang.Symbol [x]
  (let [ns     (namespace x)
        name   (name x)
        symstr (if-not (nil? ns)

           ss (apply str
                (map #(if (reserved %) (str % "$") %)
                  (string/split ss #"(?<=\.)|(?=\.)")))
           ms #?(:clj (clojure.lang.Compiler/munge ss)
                 :cljs (cljs.core/munge ss))]
       (if (symbol? s)
         (symbol ms)
         ms)))))
