Last active
March 18, 2018 03:15
-
-
Save lwhorton/3bc756cefded6d39d19e56a46c877de5 to your computer and use it in GitHub Desktop.
why-clojure#4.clj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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