I have two methods... one is basically an overload or convenience of the second. How can I easily default all of the required parameters of the convenience method?
For example, the main method is:
var doIt = function (item, varA, varB, varC, varD, callback) {
// Lots of cool stuff in here... trust me. ;-)
};
I would like my convenience method to pass in null values for the 'var' parameters:
var doItNow = function (item, callback) {
return doIt(item, null, null, null, null, callback);
};
However, I do NOT like using unnamed values.
I would like do something like:
var doItNow = function (item, callback) {
var varA = varB = varC = varD = null;
return doIt(item, varA, varB, varC, varD, callback);
};
... but WebStorm has taught me that this is a no-no. So, I am currently doing this:
var doItNow = function (item, callback) {
var varA = null,
varB = null,
varC = null,
varD = null;
return doIt(item, varA, varB, varC, varD, callback);
};
Which is fine, but it takes longer to type. And, when you're writing a ton of code, this becomes more tedious.
Sorry for the newbie question. Thanks, in advance.