title: how to use a complex return object from clojurescript in javascript
body: <p>I want to write a clojurescript function that returns a complex item like ["foo" "bar"] or (list "foo" "bar") and I want to be able to call this function from javascript and get at the parts of the return value. How can it be done? In my case, the number of items in the vector/list/collection that I'm returning is known beforehand, and the collection should remain ordered.</p>
  
  <p>Here's my clojurescript function. I could do something differently here if it made things easier. Just don't know what that would be.</p>
  
  <pre><code>(defn myFn [] ["foo" "bar"])
  </code></pre>
  
  <p>Here's what it looks like after it has been compiled to javascript. This part is completely determined/generated by the previous bit of code. To make changes here, I'd have to know how to tweak the previous part in clojurescript.</p>
  
  <pre><code>my.ns.myFn = function myFn() {
    return cljs.core.PersistentVector.fromArray(["foo", "bar"], true)
  };
  </code></pre>
  
  <p>When I do the following in javascript, I see an alert box pop up with ["foo" "bar"]</p>
  
  <pre><code>alert(my.ns.myFn());
  </code></pre>
  
  <p>But if I try the following, the alert shows "undefined" instead of "foo". </p>
  
  <pre><code>var tmp = my.ns.myFn();
  alert(tmp[0]);
  </code></pre>
  
  <p>What should I do differently to get the alert to show "foo" ? (Hmm. I guess I could write more clojurescript to use the value and see how that appears when compiled to javascript...)</p>