Skip to content

Instantly share code, notes, and snippets.

@mu-hun
Created May 1, 2020 10:30
Show Gist options
  • Select an option

  • Save mu-hun/8a2a9365efe049d7df81a49d15b85771 to your computer and use it in GitHub Desktop.

Select an option

Save mu-hun/8a2a9365efe049d7df81a49d15b85771 to your computer and use it in GitHub Desktop.
const isEqual = <T extends number | string>(first: T[], second: T[]) =>
first.length === second.length &&
first.findIndex((item, index) => item !== second[index]) === -1;
const isEqualVariableArray = <T>(...arrays: T[][]) => arrays.slice(0, arrays.length - 1).findIndex((array, index) => !isEqual<T>(array, arrays[index+1]))
console.assert(isEqualVariableArray<number>([1, 2], [1, 2], [1, 2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment