List of utility methods to do Array Multiply
multisplice()Array.prototype.multisplice = function(){ var args = arguments[0], res = []; args.sort( function(a, b){ return a - b; }); for(var i = 0; i < args.length; i++){ var index = args[i] - i; res.push( this.splice(index, 1)[0] ); ... | |
mutilate(start, end)var arr = ["Devin Hardy", "Seth Rollins", "Cole Sprouse"]; Array.prototype.mutilate = function(start, end) { var newArr = []; if (end > this.length || start > this.length) { throw new Error("Invalid opperation."); } else { arr2 = this.slice(start, end); newArr.push(arr2); return newArr; }; |