I want to create a function such as:
var func = function(arg1, arg2) {
callAnotherFunc(arg1, arg2);
}
as you can see, when someone needs to call func
, it needs to pass 2 args. sometimes, arg2 can be null.
Sometimes, arg2
will be null. Is there some shortcut which allows me to do this ?
var func = function(arg1, arg2) {
callAnotherFunc(arg1, arg2 || nothing);
}
So if arg2 is null, it shouldn't pass another argument to callAnotherFunc
at all. I am looking for some shortcut and not if/else