Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 22, 2014 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/75ad091721a4700fdd44 to your computer and use it in GitHub Desktop.
Save devdays/75ad091721a4700fdd44 to your computer and use it in GitHub Desktop.
TypeScript generics example
interface Array<T> {
// ...
map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
// ...
}
var array: Array<string> = ["John", "Sam", "George"];
var lengths = array.map((val, idx, arr) => val.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment