5 ms·
Presumably OP didn’t want to create a new function, or they would have. JavaScript supports default parameters, but again, presumably OP wanted the caller to su
by jakelazaroff 6y ago
Presumably OP didn’t want to create a new function, or they would have. JavaScript supports default parameters, but again, presumably OP wanted the caller to supply all the arguments.
If you’re trying to change the signature of an existing function, I don’t think we’ve yet figured out a better safeguard than static typing.
- colejohnson66 6y agoIt’s possible to use "arguments.length" to “change” the function signature and execute different code for different parameter counts. It’s a hack, but it works.