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

Add wrappers for Function.prototype.call() and Function.prototype.apply() #49

Open
Bubbler-4 opened this issue May 25, 2018 · 0 comments

Comments

@Bubbler-4
Copy link

When a function is stored into a variable, say U, there is no simple way to call it, especially with arguments. It is because, if you type U(, the transpiler inserts a comma between U and (. But vanilla JS has a couple of handy tools for that:

Since plenty of slots are still available for Function.prototype in Japt, I suggest to add these two methods as one-char aliases.

In place of apply, there is a more general alternative: F.d(x) = F(...x). This not only spreads array elements, but also individual chars of a string. It's a useful tool to have in vanilla JS for something like Math.max(..."12345") which calculates the largest digit of a number (though I can't think of use cases in Japt right now).

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

No branches or pull requests

2 participants