Skip to content

Instantly share code, notes, and snippets.

@quoll
Created March 20, 2014 18:51
Show Gist options
  • Save quoll/9671112 to your computer and use it in GitHub Desktop.
Save quoll/9671112 to your computer and use it in GitHub Desktop.
Calling JS functions
(ns hello
(import [javax.script ScriptEngineManager]))
(def e (.getEngineByName (ScriptEngineManager.) "nashorn"))
(def js-print (.eval e "print"))
(defn call
[f & args]
(.eval e "f.apply(null, args)" (doto (.createBindings e) (.putAll {"f" f "args" args}))))
(defn -main [& args]
(call js-print "Hello, World!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment