title: In Swift, how to invoke method of Jscript object returned by JSContext.callWithArguments
body: <p>I am new to both javascript and Swift. I am writing an IOS app, that uses
  JavaScriptCore to invoke a javascript function that returns an Object. How can I then use JavaScriptCore to invoke a method of the returned object.</p>
  
  <p>for example (I'm not actually working with rectangles), the JavaScript might be as follows:</p>
  
  <pre><code>function Rectangle(l,w) {
      this.l = l
      this.w = w
  
      function area() {
          return l * w
      };
  }
  
  function getRectangle(l,w) {
      return new Rectangle(l,w)
  }
  </code></pre>
  
  <p>And then, followng a call to jsContext.evaluateScript(jsScriptSource), the Swift calls to get a rectangle object might look like this</p>
  
  <pre><code>var getRectangle = self.jsContext.objectForKeyedSubscript("getRectangle")
  var rectangle: JSValue = getRectangle.callWithArguments([11,5])
  </code></pre>
  
  <p>how can I then invoke the getArea method of the returned rectangle?</p>
  
  <p>thanks</p>