function | since v0.0-2411 | Edit |
(js-invoke obj s & args)
Invoke JavaScript object obj
method via string s
. Needed when the string is
not a valid unquoted property name.
If we have a JavaScript object with an unusual property name:
// JavaScript
var obj = {
"my sum": function(a,b) { return a+b; }
};
We can invoke it from ClojureScript:
(js-invoke js/obj "my sum" 1 2)
;=> 3
Invoke JavaScript object method via string. Needed when the string is not a valid unquoted property name.
(defn js-invoke
[obj s & args]
(.apply (unchecked-get obj s) obj (into-array args)))