r/Clojurescript • u/_woj_ • Oct 28 '17
Function Hoisting in ClojureScript
I'm relatively new to Clojure/ClojureScript, and I was playing around in this online ClojureScript editor (http://app.klipse.tech/) when I realized that this code worked and printed to the console:
(myFunc)
(defn myFunc [] (println "hello hello"))
I'm just wondering why it knows what myFunc is before it's defined. Is is a part of Clojure or a part of JavaScript? Would this code work in JVM clojure?
5
Upvotes
View all comments
Show parent comment
1
u/_woj_ Oct 31 '17
Thanks, good point. I changed the function name and received an error. I remember Rich Hickey saying that "order of everything matters so much" in imperative languages, but order matters in Clojure as well. Or it is just that even though the order still matters, Clojure is more about working with blocks of logic rather than lines of code?