When I did
function f(...args) {return args;}
f.length // 0
And logged f.length
, it showed 0
.
Is there any way I can detect vararg parameters in JS?
When I did
function f(...args) {return args;}
f.length // 0
And logged f.length
, it showed 0
.
Is there any way I can detect vararg parameters in JS?
For further actions, you may consider blocking this person and/or reporting abuse
Nicole Zonnenberg -
Karl Esi -
Ian Kamau -
ServBay -
Top comments (3)
Rest operator supports 0 or more args. Btw it's don't count as existing argument.
As i know, at this moment no ways to detect it other than toString().
Would you elaborate on what you are trying to achieve please?
I'm working on HotTea, and I'm creating an
overloads
function.One of the things it has to do is check if there are methods with varargs parameters.
I want to check as a last resort, in case there are no overloads with
X
amount of parameters (where X is the amount of arguments you provide).Something like this:
What it does internally is looks through this list and checks some criteria.
The criteria is:
typedOverload
) The types matchIf I check the list, I need to include the varargs (I may also need a distinct way of doing this).
Hopefully this helps explain my goals better.
Thanks. Cheers!