Generics in Javascript