자바스크립트 map()

Jmnote (토론 | 기여)님의 2020년 7월 11일 (토) 22:08 판

1 개요

JavaScript map()
const array1 = [1, 4, 9, 16];
const map1 = array1.map(x => x * 2);
console.log(map1);
// [2, 8, 18, 32]
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 같이 보기

3 참고

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