자바스크립트 map()

(JavaScript map()에서 넘어옴)

1 개요[ | ]

JavaScript map()
const a = [1, 2, 3, 4];
const result = a.map(x => x * 2);
console.log(result); // [2, 4, 6, 8]
members = [
  { id: 102, name: 'Ashley Allen', address: 'Seoul' },
  { id: 202, name: 'Peter Parker', address: 'New York' },
  { id: 104, name: 'John Smith', address: 'Tokyo' }
];
console.log(members.map(x => x.address)); // [ 'Seoul', 'New York', 'Tokyo' ]

2 2차원 배열[ | ]

const arr = [[2, 3], [1, 6, 7], [5, 4, 3, 2]];
const result = arr.map(a => a.map(b => b*2));
console.log(result);

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}