functionsince v0.0-927 clojure.core/=Edit
(= x)
(= x y)
(= x y & more)


Returns true if the value of x equals the value of y, false otherwise.

= is a value comparison, not an identity comparison.

All collections can be tested for value, regardless of "depth".


(= 1)
;;=> true

(= 1 1)
;;=> true

(= 1 2)
;;=> false

(= 1 1 1)
;;=> true

(= 1 1 2)
;;=> false

Sequences are considered equal in value if they have the same elements:

(= '(1 2) [1 2])
;;=> true

But you cannot compare JavaScript arrays until you convert them to sequences:

(def a #js [1 2])
(def b #js [1 2])
(= a b)
;;=> false

(= (seq a) (seq b))
;;=> true

It is natural to compare deeply nested collections since value equality checks are cheap in ClojureScript:

(def a {:foo {:bar "baz"}})
(def b {:foo {:bar "baz"}})
(= a b)
;;=> true

(= [a b] [a b])
;=> true

JavaScript objects cannot be compared in this way until they are converted to ClojureScript collections:

(def a #js {:foo #js {:bar "baz"}})
(def b #js {:foo #js {:bar "baz"}})
(= a b)
;;=> false

(= (js->clj a)
   (js->clj b))
;;=> true

See Also:

Source docstring:
Equality. Returns true if x equals y, false if not. Compares
numbers and collections in a type-independent manner.  Clojure's immutable data
structures define -equiv (and thus =) as a value, not an identity,
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn ^boolean =
  ([x] true)
  ([x y]
    (if (nil? x)
      (nil? y)
      (or (identical? x y)
        ^boolean (-equiv x y))))
  ([x y & more]
     (if (= x y)
       (if (next more)
         (recur y (first more) (next more))
         (= y (first more)))