Polymorphism for javascript