What is the best way (or ways) to fake function overloading in Javascript?
I know it is not possible to overload functions in Javascript as in other languages. If i needed a function with two uses foo(x) and foo(x,y,z) which is the best / preffered way:
- Using different names in the first place
- Using optional arguments like y = y || 'default'
- Using number of arguments
- Checking types of arguments
- Or how?