Skip to content

Instantly share code, notes, and snippets.

View irem-kurt's full-sized avatar

Irem Kurt irem-kurt

View GitHub Profile
@muslemomar
muslemomar / demo.js
Last active June 28, 2022 15:59
Create a fixed length array
let arr = [];
arr.maxLength = 3;
Array.prototype.pushLimited = function(elem) {
if (this.length === this.maxLength) {
throw new Error('max length exceeded');
} else {
this.push(elem);
}
}