You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
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 typeU(
, the transpiler inserts a comma betweenU
and(
. But vanilla JS has a couple of handy tools for that:Function.prototype.apply
: Pass a single array of arguments to the function.Function.prototype.call
: Pass an argument list to the function.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 likeMath.max(..."12345")
which calculates the largest digit of a number (though I can't think of use cases in Japt right now).The text was updated successfully, but these errors were encountered: