Created
May 13, 2012 18:17
-
-
Save mason-stewart/2689596 to your computer and use it in GitHub Desktop.
cljs question
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
| (ns masondesu.main) | |
| (def x "foo") | |
| (.log js/console x) ;; logs "foo". outputs `console.log(masondesu.main.x)` | |
| (def mason (js-obj name "Mason Stewart" beardPower 5000)) | |
| (.log js/console mason.name ) ;; throws error. outputs `console.log(mason.name)` |
Author
mason.name is not valid ClojureScript property access:
For interop purposes you want this:
(def mason (js-obj "name" "Mason Steward" "beardPower" 5000))
(.log js/console (aget mason "name"))But if you're writing idiomatic Clojure:
(def mason {:name" "Mason Steward" :beard-power" 5000})
(.log js/console (:name mason))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is the namespacing incorrect on the second console.log() ?