How to write an extension-method in JavaScript
The following code adds a method to the Array object. Array.prototype.remove = function (index) { const temp = [].concat(this); return [].concat(temp.slice(0, index)).concat(temp.slice(index + 1)); }; let arr = [0, 1, 2, 3, 4, 5]; console.log(arr.remove(3)) The mechanism works: the remove…