So as i have commented above you might do this by array sub-classing. The following snippet introduces a new Array structure with two new methods as last and push. However our new push shadows the real push method of the Array.prototype. The new push takes the first argument as the limit to the array length such as [1,2,3].push(4,"a","b","c") will limit the length to 4 and the result would be [3,"a","b","c"]. The return value will be the deleted elements in an array as we are using splice under the hood.
function SubArray(...a) {
Object.setPrototypeOf(a, SubArray.prototype);
return a;
}
SubArray.prototype = Object.create(Array.prototype);
SubArray.prototype.last = function() {
return this[this.length - 1];
};
SubArray.prototype.push = function(lim,...a){
Array.prototype.push.apply(this,a);
return this.splice(0,this.length-lim);
};
myArray = new SubArray(1,2,3);
myArray.last();
myArray.push(4,"a","b","c");
console.log(myArray);