These days, I was trying to utilize function hash in clojure/clojurescript to generate unique id, but it turns out this function has very strange behaviour to empty vector parsed from read-string in cljs with in clj.
In clojure, hash function return -2017569654 for empty vector and the one parsed from read-string
user=> (hash [])
-2017569654
user=> (hash (read-string "[]"))
-2017569654
However, in cljs, (hash []) returns surprisingly 0. And [] are also equal to (read-string "[]").
cljs.user=> (hash (cljs.reader/read-string "[]"))
-2017569654
cljs.user=> (hash [])
0
cljs.user=> (= [] (cljs.reader/read-string "[]"))
true
Does any one know the reason of it and how to solve it in cljs?