What is the best way(s) 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 / preferred way:

  1. Using different names in the first place
  2. Using optional arguments like y = y || 'default'
  3. Using number of arguments
  4. Checking types of arguments
  5. Or how?

37 s
37

Leave a Reply

Your email address will not be published. Required fields are marked *