0

I am testing om (https://github.com/omcljs/om) and I don't understand whats happen here:

I have a Clojure code that consume a API and put data into a vector. Then in my ClojureScript code I try:

(def urls (map (fn [c] (get c :url )) billings))
(def n (first urls))

(println n) ;; correct value
(.log js/console n) ;; null

Someone can explain this behavior ?

Thanks

1 Answer 1

1

If you are using a REPL, then println will—assuming you haven't issued (enable-console-print!)—generally print to your REPL. But, console.log goes to your browser's console output.

When you invoke (.log js/console n), the REPL only prints the return value of console.log, so you see nil.

Sign up to request clarification or add additional context in comments.

4 Comments

Mike, I see null on browser (console). So how I can see this value on browser ?
It is making me wonder if n is handled differently when converted to a string for printing (in that you have some odd sort of object). If you do (println (str n)) compared to (.log js/console (str n)) do you get different results?
(println (str n)) print correct value and (.log js/console (str n)) print null (on browser)
Wow. How about the behavior of (let [s (str n)] (println s) (.log js/console s))?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.