title: Object.keys function in JS file that runs from Java
body: <p>When I try to use <code>Object.keys</code> function in JavaScript file that runs as Java application I get Exception.</p>
  
  <p>I want to use some function from JS file like this:</p>
  
  <pre><code>    function calculateProductPrice(orderData)
      {
          ...
          k = Object.keys(prices);    
          for (var i = k.length; i &gt; -1; i--)
          {
              ...
          }       
          ...     
      }
  
      var prices = {
               "1":[
                  99,
                  106,
                  113,
                 ...
  </code></pre>
  
  <p>Fragment of java code that use this script:</p>
  
  <pre><code>Context context = Context.enter();
  ScriptableObject  scope = context.initStandardObjects();
  FileReader fr = new FileReader("script.js");
  context.evaluateReader(scope, fr, "&lt;cmd&gt;", 1, null);
  Object orderData = Context.javaToJS(new OrderData(), scope);
  scope.put("orderData", scope, orderData);
  Object result = context.evaluateString(scope, "calculateProductPrice(orderData)", "&lt;cmd&gt;", 1, null);
  </code></pre>
  
  <p>And I get Exception:</p>
  
  <pre><code>Exception in thread "main" org.mozilla.javascript.EcmaError: TypeError: Cannot find function keys in object function Object() { [native code for Object.Object, arity=1] }
  . (&lt;cmd&gt;#11)
      at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
      at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
      at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
      at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
      at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3743)
      at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2247)
      at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2214)
      at org.mozilla.javascript.gen.c1._c1(&lt;cmd&gt;:11)
      at org.mozilla.javascript.gen.c1.call(&lt;cmd&gt;)
      at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
      at org.mozilla.javascript.gen.c2._c0(&lt;cmd&gt;:1)
      at org.mozilla.javascript.gen.c2.call(&lt;cmd&gt;)
      at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
      at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
      at org.mozilla.javascript.gen.c2.call(&lt;cmd&gt;)
      at org.mozilla.javascript.gen.c2.exec(&lt;cmd&gt;)
      at org.mozilla.javascript.Context.evaluateString(Context.java:1104)
      at net.terraincognita.restapi.service.ScriptEngine.&lt;init&gt;(ScriptEngine.java:65)
      at net.terraincognita.restapi.service.ScriptEngine.main(ScriptEngine.java:94)
  Java Result: 1
  </code></pre>