How to write JavaScript unshift and shift array methods from scratch
unshift
Add an element to the front of an array
Array.prototype._unshift = function(...values) {
const newArray = [...values, ...this]
this.length = 0
this.push(...newArray)
return this.length;
};
const fruits = ['apple', 'mango', 'banana']...
blog.devbitbyte.com1 min read