Array.prototype.map()

/*arr.map(callback[, thisArg]);
 * callback
 *     currentValue
 *     index
 *     array
 */
var fruitsArr = ['banana', 'apple', 'strawberry'];
fruitsArr.map(function(cv, ind, arr){
    console.log('crrentvalue = ' + cv + ', index = ' + ind + ', array = ' + arr);
});

var foodsArr = [
    ['apple','100','aomori'],
    ['beef','300','hyogo'],
    ['mango','200','miyazaki'],
];
foodsArr.map(function(cv, ind, arr){
    console.log('crrentvalue = ' + cv + ', index = ' + ind + ', array = ' + arr);
});

See the Pen js: map() by nwstcode (@nwst) on CodePen.

 

TagTimes

Simple time tracking tool
Developed by Namu Works