-
Notifications
You must be signed in to change notification settings - Fork 27
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
Plans for array prototype methods? #64
Comments
The short answer is that there's a long-term plan to add them but no short-term plan, but you can add them yourself in your particular app if you need them. The longer answer is this:
Having said that, if someone in the Microvium community wanted to create a library of these methods for other people to use, that would be great. |
I see that these make it larger, but hard to implement pop(), as it both returns the popped value and modifies the array. I'm happy to add them on my own and share the code, can you point me to how to do that? I would implement it in C, to not grow the bytecode significantly, but no idea how to add it to the object. |
Probably something like this would work, although I haven't tried it. const arrayProto = [].__proto__;
arrayProto.pop = function() {
const len = this.length;
const last = this[len - 1];
this.length = this.length - 1;
return last;
} Let me know if you have issues with that. |
Looks good and works well, thanks. :) |
Let me close this issue, I think it is already works well enough. |
As far as I see, only push, length and [num] getters are currently supported for arrays. What is the plan about adding the basics like pop, shift, unshift? Maybe some more?
The text was updated successfully, but these errors were encountered: