@Description: This emulates Array.prototype.reduceRight from javascript 1.6 and is taken from the MDC site reference. .reduceRight executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.
The call to the reduce callback would look something like this:
@File: Array/prototype/reduceRight.js
@Param: function The function to apply the array elements to
@Example:myArray.reduceRight(function(previousValue, currentValue, index, array){
// ...
})
//real examples
var total = [0, 1, 2, 3].reduceRight(function(a, b) { return a + b; });
// total == 6
var flattened = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) {
return a.concat(b);
}, []);
// flattened is [4, 5, 2, 3, 0, 1]