# Returning array from JS

**URL:** <https://forum.anaconda.com/t/returning-array-from-js/39417>\
**Category:** PyScript\
**Created:** [September 25, 2022, 3:46am UTC](https://forum.anaconda.com/t/returning-array-from-js/39417 "2022-09-25T03:46:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gunnar](https://avatars.discourse-cdn.com/v4/letter/g/c2df01/32.png) [@gunnar](https://forum.anaconda.com/u/gunnar)\
**Post date:** [September 25, 2022, 3:46am UTC](https://forum.anaconda.com/t/returning-array-from-js/39417/1 "2022-09-25T03:46:25Z")

</div>

What is the best way to return an array from JS? If I just return a JS array, I need to call .to\_py() in python to make it useful. I would like to handle this in the JS code. If pyodide was accessible, I would call pyodide.toPy(). Is the pyodide runtime perhaps surfaced anywhere? Thanks!

---

<div class="post-metadata">

**Author:** ![john.hanley](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/john.hanley/32/1294_2.png) [@john.hanley](https://forum.anaconda.com/u/john.hanley)\
**Post date:** [September 26, 2022, 5:07am UTC](https://forum.anaconda.com/t/returning-array-from-js/39417/2 "2022-09-26T05:07:29Z")

</div>

At this time, PyScript does not publish a handle to Pyodide.

I think that will change when Pyodide version 0.21.3 is integrated into Pyscript.

---

<div class="post-metadata">

**Author:** ![JeffGlass](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/jeffglass/32/1301_2.png) [@JeffGlass](https://forum.anaconda.com/u/JeffGlass)\
**Post date:** [September 26, 2022, 4:02pm UTC](https://forum.anaconda.com/t/returning-array-from-js/39417/3 "2022-09-26T16:02:32Z")

</div>

If you’re experimenting, there are some (admittedly hacky) ways to work around this, by using JavaScript’s `eval()` to export Python objects (or Pyodide objects, which can be imported within PyScript like pyodide.toPy) to the JavaScript namespace.

I [wrote up some details on this process recently](https://jeff.glass/post/pyscript-js-functions/) if you’re interested. Of course the cleaner way would be to have Pyodide exported from PyScript, but that’s not currently the case.
