title: Pass dynamically constructed object as a parameter to JS function with Rhino
body: <p>I hope it's a simple question but I cannot find an answer. I use Map as a way to pass parameters to the function in Nashorn. How could I pass dynamically constructed object as a function parameter in Rhino? Cannot find it anywhere. Example would be just great. I need to pass something like that:</p>
  
  <pre><code>{
     field1: "value1",
     field2: 2,
     someotherField: "another"
  }
  </code></pre>
  
  <p>etc but created dynamically in runtime. I need to pass it to the compiled js function, like that:</p>
  
  <pre><code>String src="function fooname(params) {\n"+
                      "   for(var key in params)\n" +
                      "   {\n" +
                      "     print(key+\" : \"+params[key])\n" +
                      "   }\n" +    
                      "}\n";
  Context context = Context.enter();
  Script script = context.compileString(src, "testSource", 0, null);
  script.exec(context, scope);
  Function foo = (Function) scope.get("fooName", scope);
  foo.call(context, scope, scope, params);
  </code></pre>
  
  <p>I need to assign to these "params" (for example to the params[0]) a dynamically created js object.</p>