declare global { interface Array { /** @summary check if any of the elements of `arr2` are included in `this` */ anyOf(arr2: Array): boolean; /** @summary return last element of array without removing it */ peek(): T; /** @summary create Set from this array */ set(): Set; } } Array.prototype.anyOf = function(arr2) { return !!this.filter(e => arr2.includes(e)).length; }; Array.prototype.peek = function() { return this[this.length - 1]; }; Array.prototype.set = function() { return new Set(this); }