develog

[jquery] map 본문

카테고리 없음

[jquery] map

냐옴 2022. 11. 5. 08:14

 

let list = [11, 22, 33];
// [11, 22, 33]
console.log('list', list);

let list2 = $.map(list, function(item, index) {
    console.log(index, item);
    return item * 10;
});

// [11, 22, 33]
console.log('list', list);

// [110, 220, 330]
console.log('list2', list2);

 

https://api.jquery.com/jquery.map/

 

jQuery.map() | jQuery API Documentation

Description: Translate all items in an array or object to new array of items. If you wish to process a jQuery object — for example, $('div').map( callback ); — use .map() instead. The $.map() method applies a function to each item in an array or object

api.jquery.com

 

Comments