Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to index js array #1016

Closed
JoeHowarth opened this issue Nov 8, 2018 · 3 comments
Closed

How to index js array #1016

JoeHowarth opened this issue Nov 8, 2018 · 3 comments

Comments

@JoeHowarth
Copy link

This seems like a simple thing I'm missing, but how do you index into a js array?

fn foo(arr: js_sys::Array) {
     let a = arr[0]   <--- or something
}
@fitzgen
Copy link
Member

fitzgen commented Nov 8, 2018

Right now, you can use Reflect::get: https://docs.rs/js-sys/0.3.4/js_sys/struct.Reflect.html#method.get

We may want to add a specific method for this, however.

@JoeHowarth
Copy link
Author

Ahh, this was what I missed!
Thanks!

@ArhanChaudhary
Copy link

Note to future readers that specific methods for this have been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants