title: Javascript argument with multiple data types allowed: good practice or not?
body: <p>Many times I have seen - especially in jQuery - that a function can have multiple valid data types, let's say either a string or a function. Also, in my own code I sometimes have functions which can take one <em>or</em> several values. So I could call the function with:</p>
  
  <pre><code>myFunc("arg"); or myFunc(["arg1", "arg2", ...]);
  </code></pre>
  
  <p>This appears to be more flexible and also more convenient to type, but is this actually a good thing?</p>
  
  <p>Because on the other hand, it is not explicitly stated what type the function is, and AFAIK then the JIT compiler cannot work as efficently. And often there has to be a type coercion of some type then, which can introduce an additional performance penalty.</p>
  
  <p>So, would it be better to <em>always</em> write: <code>myFunc(["arg"])</code> even if there is only one object in the array? What's your take on this? </p>