Created
January 7, 2023 00:39
-
-
Save javierd79/93a4f9aec7b22e9a269bd6c743419324 to your computer and use it in GitHub Desktop.
Array prototype extension to get duplicate objects in an array
This file contains 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
interface Array<T> { | |
has(key: string, value: any): [keyof T, any] | [] | |
} | |
Array.prototype.has = function(key, value) { | |
return this.filter((item) => item[key] === value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment