jslint - Get warning when passing too few arguments to a javascript function -


is there tool can me detect when javascript function being passed few arguments? far can tell, neither jslint nor jshint provides feature.

just make clear, if write:

some_method = function(x,y) {   // ..do stuff } some_method(2); 

i warned, might have pass in argument.

you can't that, parameters optional , can pass indefinite amount of parameters parameterless function (through arguments array).

but can use arguments array test own methods manually. have add each method individually, since can't reflect amount of arguments in method signature. specific case use:

function test(x, y) {   if (arguments.length !== 2)     {       console.log('error, invalid amount of args');     } }  test(1); // trigger console.log , type error. 

if need parameter checking use typescript, parameters required default.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -