Created
October 28, 2021 06:43
-
-
Save hamzakaya/faa943789d0d2b8473f866c5a84de384 to your computer and use it in GitHub Desktop.
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
function limitArray(length: number): any[] { | |
const arr = new Array() | |
arr.push = function () { | |
if (this.length >= length) this.shift() | |
return Array.prototype.push.apply(this, arguments) | |
} | |
return arr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment