Assuming ES5
You should switch to passing objects to your function:
var foo = function(options){
var first = options.first;
var second = options.second;
var third = options.third;
...
}
This way, you have a much cleaner Interface foo({first:"Test", third:"Test3"})
You name the parameters, you want to set explicitely. This has the upside of no necessity to remember in which sequence the parameters have to be called and to remember whether null or undefined was the 2nd parameter and you see what maps to what.
Assuming ES6+
This becomes in ES6 parameter context matching:
const foo = ({first, second, third})=>{...}
foo({first:"Test", third:"Test3"})
There is a bit of implicit destructuring "magic":
foo({first:"Test", third:"Test3"})
behaves like
foo(obj)
and
const foo = ({first, second, third})=>{...}
is equivalent to:
const foo = (options)=>{
const {first, second, third} = options;
...
}
which is equivalent to the ES5 solution with object matching (a subkind of destructuring) added.
And object matching behaves like the ES5 solution above.
tl;dr
Recommendation: Refactor your code, avoiding positional arguments at all.
undefinedis implicitly passed for the arguments you don't specify.