Created
July 5, 2012 23:26
-
-
Save presci/3057097 to your computer and use it in GitHub Desktop.
erlang_js examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1> {ok, JS}=js_driver:new(). | |
{ok,#Port<0.1611>} | |
2> js:define(JS, <<"var hello=function(){return 'hello world';}">>). | |
ok | |
3> js:call(JS, <<"hello">>, []). | |
{ok,<<"hello world">>} | |
4> js:define(JS, <<"var kelly=function(){ return {\"hello\":\"world\"};}">>). | |
ok | |
5> js:call(JS, <<"kelly">>, []). | |
{ok,{struct,[{<<"hello">>,<<"world">>}]}} | |
6> js:define(JS, <<"var discovery=function(){return [{\"hello1\":\"world\"},{\"hello2\":\"world2\"}];}">>). | |
ok | |
7> js:call(JS, <<"discovery">>, []). | |
{ok,[{struct,[{<<"hello1">>,<<"world">>}]}, | |
{struct,[{<<"hello2">>,<<"world2">>}]}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment