Skip to content

Instantly share code, notes, and snippets.

@zerovolts
Last active July 5, 2018 07:08
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 zerovolts/31e70a2232c3eab9c7ca2b9c58ec8c5c to your computer and use it in GitHub Desktop.
Save zerovolts/31e70a2232c3eab9c7ca2b9c58ec8c5c to your computer and use it in GitHub Desktop.

function keyword

function first0<T>(arr: T[]): T { return arr[0]; }
const first1 = function <T>(arr: T[]): T { return arr[0]; }

Arrow Functions

const first2 = <T>(arr: T[]): T => arr[0];
const first3: <T>(arr: T[]) => T = (arr) => arr[0];
const first4: <T>(arr: T[]) => T = <T>(arr: T[]): T => arr[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment