Javascript Multiple Dispatch