arrays Various ways of accessing arrays Applying a Function to Every Value of an Array in Javascript


Example

var numbers = [1,2,3,4,5];
var squares = numbers.map(function(x) {
    return x*x;
});

// squares is [1,4,9,16,25]