   "Converts a cljs data structure into a close JS approximation."
   ([obj flat visited]
    (cond
+     (= (type obj) Atom) (->js @obj flat visited)
      (keyword? obj)      (name obj)
      (symbol? obj)       (name obj)
-     (= (type obj) Atom) (->js @obj flat visited)
+     (map? obj)          (map->js obj flat visited)
      (seq? obj)          (seq->js obj flat visited)
      (set? obj)          (seq->js obj flat visited)
-     (map? obj)          (map->js obj flat visited)
+     (vector? obj)       (seq->js obj flat visited)
      :else               obj))
 
   ([obj flat] (->js obj flat (atom {})))
   ([obj] (->js obj false (atom {}))))
 
 
-(.log js/console (let [a (atom [1])
-      b [9 a]
-      a-js (array 1)
-      b-js (array 9 a-js)]
+;;***************************************************************************
+;; deep=
+;;***************************************************************************
+(def deep=)
 
-  (swap! a conj b)
-  (.push a-js b)
+(defn deep-arr=
+  ([val1 val2 visited]
+   (if (= (count val1) (count val2))
+     (every? identity (map #(deep= % %2 visited) val1 val2))
+     false)))
 
-  (seq->js b true)))
+(defn deep-obj=
+  ([val1 val2 visited]
+  (if (and (= (obj-size val1) (obj-size val2))
+           (deep-arr= (.keys js/Object val1)
+                      (.keys js/Object val2)
+                      visited))
+    (every? identity
+            (map #(deep= (aget val1 %) (aget val2 %) visited)
+                 (.keys js/Object val1)))
+    false)))
+
+(defn deep=
+  "Compares JS values for equality by value instead of by reference."
+  ([val1 val2 visited]
+   (cond
+    (and (arr? val1) (arr? val2)) (deep-arr= val1 val2 visited)
+    (and (obj? val1) (obj? val2)) (deep-obj= val1 val2 visited)
+    :else (= val1 val2)))
+
+  ([val1 val2] (deep= val1 val2 (atom {}))))

(ns overcode.introvert)

(def ->js)

(defn array-append [arr seq]
  "Inserts all elements from a Seq into an existing JS array."

   (swap! visited assoc obj out)
   out)

  ([visited obj] (visit! visited obj "Circular Ref")))


;;***************************************************************************
;; ->js
;;***************************************************************************
(def ->js)
(defn seq->js
  "Converts a seq-like value into a JS Array."
  ([obj flat visited]
