So I admit that I’m new to javascript and that I come from a C.+ background (‘Hi, I’m Bob, I’m a class-based static language user’, chorus ‘hi Bob!’).
I find that I often end up writing functions like:
function someFunc() { if (arguments.length === 0 ){ ... } else { ... } }
(where there might be three such cases). Or, alternatively, I write the difference into the name:
function someFuncDefault() { ... }; function someFuncRealArg(theArg) { ... };
(Substitute ‘RealArg’ for some semantically contentful phrase).
Is there a better pattern for this kind of thing?
Have a look at this post.