Here you can find the source of map(projectionFunction)
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(function(itemInArray) { // ------------ INSERT CODE HERE! ---------------------------- // Apply the projectionFunction to each item in the array and add // each result to the results array. // Note: you can add items to an array with the push() method. // ------------ INSERT CODE HERE! ---------------------------- results.push(projectionFunction(itemInArray)); });//from w w w. j av a2 s. co m return results; }; // JSON.stringify([1,2,3].map(function(x) { return x + 1; })) === '[2,3,4]'
Array.prototype.map = function(projectionFunction) { var reuslts = []; this.forEach(function(itemInArray){ results.push(projectionFunction(itemInArray)); }) return results;
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(function(itemInArray) { results.push(itemInArray+1); }); console.log(results); return results; };
Array.prototype.map = function (projectionFunction) { var results = []; this.forEach(function (itemInArray) { results.push(projectionFunction(itemInArray)); }); return results; };
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(function(itemInArray) { results.push(projectionFunction(itemInArray)); }); return results; };
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(function(itemInArray) { results.push(projectionFunction(itemInArray)); }); return results; }; console.log(JSON.stringify([1,2,3].map(function(x) { return x + 1; })))
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(function(itemInArray) { results.push(projectionFunction(itemInArray)); }); return results; }; var answer = JSON.stringify([1,2,3].map(function(x) { return x + 1; })) === '[2,3,4]'; console.log(answer); ...
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(itemInArray => results.push(projectionFunction(itemInArray)) ); return results; };
Array.prototype.map = function (projectionFunction) { var results = []; this.forEach(function (itemInArray) { results.push(projectionFunction(itemInArray)); }); return results; };
Array.prototype.map = function(projectionFunction) { var results = []; this.forEach(function(itemInArray) { }); return results; }; JSON.stringify( [1,2,3].map(function(x) { return x + 1; ...