Skip to content

Instantly share code, notes, and snippets.

@lwhorton
Last active March 18, 2018 03:15
Show Gist options
  • Select an option

  • Save lwhorton/3bc756cefded6d39d19e56a46c877de5 to your computer and use it in GitHub Desktop.

Select an option

Save lwhorton/3bc756cefded6d39d19e56a46c877de5 to your computer and use it in GitHub Desktop.
why-clojure#4.clj
(let [arr []]
(type arr) ;; clojure.lang.PersistentVector
(instance? clojure.lang.PersistentVector arr) ;; true
)
(= 1 "1") ;; false
(= 1 [1]) ;; false
(= 0 false) ;; false
(= "" false) ;; false
(= nil false) ;; false
(= "0" true) ;; false
(= "false" true) ;; false
(= [] true) ;; false
(= {} true) ;; false
(= (fn [] nil) true) ;; false
(= [] ",,") ;; false
(+ (- (/ (* 1 1) 2) 4) 2)
;; or more commonly
(-> (* 1 1)
(/ 2)
(- 4)
(+ 2)) ;; -1.5
var arr = new Array
arr.constructor === Array // true, but constructor can be modified
arr instanceof Array // oops, barfs
Object.prototype.toString.call(arr) === '[object Array]' // true because, I mean, why not?
Array.isArray(arr) // true, finally!
Array.isArray(Array.prototype) // true, huh?
typeof arr == 'object' // true, but it's a string?
arr = undefined
typeof arr // 'undefined', another string?
1 == '1' // true
1 == [1] // true
1 === '1' // false
1 === [1] // false
0 == false // true
'' == "" == false // true
null == false // true
undefined == false // true
NaN == false // true
'0' == true // true
'false' == true // true
[] == true // true
{} == true // true
function() {} == true // true
Array(3) == ",," // true
1 * 1 / 2 - 4 + 2 // quick, what's the output?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment