Created
May 1, 2020 10:30
-
-
Save mu-hun/8a2a9365efe049d7df81a49d15b85771 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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