The simplest way that I know avoids performance locks, variables, extra overhead, and global variables:
result= [2, 5, 3, 7].map(function(a){ return { x: this[0]+=a }; }, [0]);
JS provides the rarely used 2.map () parameter to store any state that is required between iterations.
Most likely, this does not work out easier, but I donβt know the coffee, sorry ...
EDIT: demo of a bilingual demo (js + cs): http://pagedemos.com/maptranforms/
source share