js-invoke

functionsince v0.0-2411Edit
(js-invoke obj s & args)

Details:

Invoke JavaScript object obj method via string s. Needed when the string is not a valid unquoted property name.


Examples:

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

Source docstring:
Invoke JavaScript object method via string. Needed when the
string is not a valid unquoted property name.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn js-invoke
  [obj s & args]
  (.apply (unchecked-get obj s) obj (into-array args)))