"자바스크립트 map()"의 두 판 사이의 차이

2번째 줄: 2번째 줄:
;JavaScript map()
;JavaScript map()


<source lang='javascript'>
const array1 = [1, 4, 9, 16];
const map1 = array1.map(x => x * 2);
console.log(map1);
// [2, 8, 18, 32]
</source>
<source lang='javascript'>
<source lang='javascript'>
members = [
members = [

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 }}