Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Created November 16, 2017 15:49
Show Gist options
  • Save pesterhazy/42c94768ed3dd991ea83ae96b4a6f57e to your computer and use it in GitHub Desktop.
Save pesterhazy/42c94768ed3dd991ea83ae96b4a6f57e to your computer and use it in GitHub Desktop.
clojurescript js-obj destructuring - thought experiment
;; How about this syntax for JS object destructuring?
(require '[js.destructuring :as j])
(j/let [^:js-obj {background-color "backgroundColor", :keys [color]} #js{:backgroundColor "red", :color "red"}]
(prn background-color color))
;; or maybe...
(j/let [:js-obj {background-color "backgroundColor", :keys [color]} #js{:backgroundColor "red", :color "red"}]
(prn bakcground-color color))
(j/defn myfn [:js-obj {:keys [foo bar]}]
(prn foo bar))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment