Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript interop assignment in Clojurescript

Dumb question: how do I do Javascript assignment in Clojurescript ? I'm using a Javascript lib and need to set the value of an object's field like obj.this=that; - I don't know Javascript so maybe there's a .set method ?

like image 201
Hendekagon Avatar asked Sep 28 '11 00:09

Hendekagon


2 Answers

Try some thing like

(set! (.-property foo) 5)
like image 102
dnolen Avatar answered Nov 19 '22 03:11

dnolen


Use

(aset foo "property" 5)

Be aware, that symbolic references may fail.

like image 11
freeduck Avatar answered Nov 19 '22 04:11

freeduck