Skip to content

Instantly share code, notes, and snippets.

@jbmilgrom
Last active August 19, 2019 22:14
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 jbmilgrom/6c4f11c1e122c4a29c4407e8121cc44c to your computer and use it in GitHub Desktop.
Save jbmilgrom/6c4f11c1e122c4a29c4407e8121cc44c to your computer and use it in GitHub Desktop.
type NumberPair = readonly [number, number];
const areNumbersEqual = (a: number, b: number) => a === b;
const areNumberPairsEqual = (a: NumberPair, b: NumberPair) =>
areNumbersEqual(a[0], b[0]) && areNumbersEqual(a[1], b[1]);
const p1 = [1, 2] as const;
const p2 = [1, 2] as const;
const p3 = [1, 3] as const;
areNumberPairsEqual(p1, p2); // true
areNumberPairsEqual(p1, p3); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment