Skip to content

Instantly share code, notes, and snippets.

@lwhorton
Created March 18, 2018 01:54
Show Gist options
  • Save lwhorton/f8a7ce8668878b81802e074b5868dd5a to your computer and use it in GitHub Desktop.
Save lwhorton/f8a7ce8668878b81802e074b5868dd5a to your computer and use it in GitHub Desktop.
why-clojure#2.clj
;; refs are never mutated
;; equality is value-based, not identity based
;; but you can still compare identity
(let [a [1 2 3]
b (conj a 4)]
(prn a) ;; [1 2 3]
(prn b) ;; [1 2 3 4]
(= a b) ;; false
(= a (drop-last b)) ;; true
(identical? a (drop-last b)) ;; false
)
var a = [1, 2, 3]
var b = a.push(4)
console.log(a) // [1, 2, 3, 4]
console.log(b) // 4, heh
b = [1, 2, 3, 4]
console.log(a == b) // false
console.log(a === b) // false
;[1,2,3] == [1,2,3] // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment