If you decide to change the Array prototype, select the option:
Array.prototype.zip = function (other, reduce, thisArg) { var i, result = [], args, isfunc = typeof reduce == "function", l = Math.max(this.length, other.length); for (i=0; i<l; i++) { args = [ this[i], other[i] ]; result.push( isfunc ? reduce.apply(thisArg, args) : args ); } return result; } var A = [2,6,12,18] var B = [2,3,4,6] var C = A.zip(B, function (l, r) { return l / r; });
source share