Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created December 5, 2016 17:13
Show Gist options
  • Save amalloy/30d4d4808fcc7e18bebcc454de681dd0 to your computer and use it in GitHub Desktop.
Save amalloy/30d4d4808fcc7e18bebcc454de681dd0 to your computer and use it in GitHub Desktop.
cljs.user=> (def obj (js-obj {}))
cljs.user=> (def foo (fn [x] (this-as this [this x])))
cljs.user=> (set! (.-f obj) foo)
cljs.user=> (.f obj 1)
[#js {:f #object[cljs$user$foo "function cljs$user$foo(x){
var this$ = this;
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [this$,x], null);
}"]} 1]
cljs.user=> ((.-f obj) obj 1)
[#object[Window [object Window]] #js {:f #object[cljs$user$foo "function cljs$user$foo(x){
var this$ = this;
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [this$,x], null);
}"]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment