{"id":6372,"date":"2026-06-28T13:47:03","date_gmt":"2026-06-28T04:47:03","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=6372"},"modified":"2026-09-28T13:47:11","modified_gmt":"2026-09-28T04:47:11","slug":"javascript-array-map-practical-guide","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/6372\/","title":{"rendered":"JavaScript map\u306e\u4f7f\u3044\u65b9\uff5c\u914d\u5217\u5909\u63db\u306e\u57fa\u672c"},"content":{"rendered":"<p>map\u306f\u300c\u914d\u5217\u3092\u9806\u756a\u306b\u51e6\u7406\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u300d\u3068\u3060\u3051\u899a\u3048\u308b\u3068\u3001forEach\u3084Map\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u306e\u9055\u3044\u3067\u8ff7\u3044\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002Array.prototype.map\u306e\u8981\u70b9\u306f\u3001\u5404\u8981\u7d20\u3092\u5909\u63db\u3057\u305f\u7d50\u679c\u304b\u3089\u65b0\u3057\u3044\u914d\u5217\u3092\u4f5c\u308b\u3053\u3068\u3067\u3059\u3002\u5b9f\u52d9\u3067\u4f7f\u3046\u5f62\u3068\u3001\u3064\u307e\u305a\u304d\u3084\u3059\u3044\u30dd\u30a4\u30f3\u30c8\u3092\u9806\u306b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<h2>\u307e\u305a\u7d50\u8ad6\uff1amap\u306f\u5404\u8981\u7d20\u3092\u5909\u63db\u3057\u3066\u65b0\u3057\u3044\u914d\u5217\u3092\u8fd4\u3059<\/h2>\n<p>MDN\u3067\u306fmap\u306f\u914d\u5217\u306e\u5404\u8981\u7d20\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u5b9f\u884c\u3057\u3001\u305d\u306e\u7d50\u679c\u3067\u65b0\u3057\u3044\u914d\u5217\u3092\u4f5c\u308b\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066\u8aac\u660e\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u5143\u914d\u5217\u304b\u3089\u5225\u306e\u5f62\u306e\u914d\u5217\u3092\u4f5c\u308a\u305f\u3044\u5834\u9762\u306b\u5411\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code>const prices = [100, 200, 300];\r\nconst taxed = prices.map(price =&gt; price * 1.1);\r\n\r\nconsole.log(taxed); \/\/ [110, 220, 330]<\/code><\/pre>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1aArray.prototype.map<\/strong><br \/>\u914d\u5217\u306e\u5404\u8981\u7d20\u3092\u5909\u63db\u3057\u3001\u305d\u306e\u623b\u308a\u5024\u3092\u8981\u7d20\u3068\u3059\u308b\u65b0\u3057\u3044\u914d\u5217\u3092\u8fd4\u3059\u6a19\u6e96\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002Map\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u306f\u5225\u7269\u3067\u3059\u3002<\/p>\n<\/blockquote>\n<hr>\n<h2>1. object\u914d\u5217\u304b\u3089\u5fc5\u8981\u306a\u5024\u3060\u3051\u53d6\u308a\u51fa\u3059<\/h2>\n<p>API\u30ec\u30b9\u30dd\u30f3\u30b9\u3084\u4e00\u89a7\u30c7\u30fc\u30bf\u3067\u306f\u3001object\u914d\u5217\u304b\u3089\u8868\u793a\u7528\u306e\u5f62\u3078\u5909\u63db\u3059\u308b\u7528\u9014\u304c\u3088\u304f\u3042\u308a\u307e\u3059\u3002\u5fc5\u8981\u306a\u30d7\u30ed\u30d1\u30c6\u30a3\u3060\u3051\u3092\u8fd4\u3059\u3068\u3001\u5f8c\u7d9a\u51e6\u7406\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u660e\u78ba\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>const users = [\r\n  { id: 1, name: &#39;Sato&#39; },\r\n  { id: 2, name: &#39;Suzuki&#39; }\r\n];\r\n\r\nconst labels = users.map(user =&gt; ({\r\n  value: user.id,\r\n  label: user.name\r\n}));<\/code><\/pre>\n<hr>\n<h2>2. callback\u3067\u306felement\u30fbindex\u30fbarray\u3092\u53d7\u3051\u53d6\u308c\u308b<\/h2>\n<p>map\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306b\u306f\u73fe\u5728\u306e\u8981\u7d20\u3001index\u3001\u5143\u306e\u914d\u5217\u304c\u6e21\u3055\u308c\u307e\u3059\u3002index\u306f\u8868\u793a\u756a\u53f7\u306e\u4f5c\u6210\u306a\u3069\u306b\u4f7f\u3048\u307e\u3059\u304c\u3001React\u306ekey\u306e\u3088\u3046\u306b\u30c7\u30fc\u30bf\u8b58\u5225\u5b50\u304c\u5fc5\u8981\u306a\u5834\u9762\u3067\u306f\u5b89\u5b9a\u3057\u305fID\u3092\u512a\u5148\u3057\u307e\u3059\u3002<\/p>\n<pre><code>const names = [&#39;A&#39;, &#39;B&#39;, &#39;C&#39;];\r\nconst rows = names.map((name, index) =&gt; `${index + 1}: ${name}`);<\/code><\/pre>\n<hr>\n<h2>3. \u6ce2\u62ec\u5f27\u3092\u4f7f\u3046\u3068\u304d\u306freturn\u3092\u66f8\u304d\u5fd8\u308c\u306a\u3044<\/h2>\n<p>\u30a2\u30ed\u30fc\u95a2\u6570\u3067\u6ce2\u62ec\u5f27\u3092\u4f7f\u3046\u5834\u5408\u3001\u660e\u793a\u7684\u306areturn\u304c\u5fc5\u8981\u3067\u3059\u3002return\u3092\u66f8\u304b\u306a\u3044\u3068\u5404\u8981\u7d20\u306e\u7d50\u679c\u304cundefined\u306b\u306a\u308a\u3001\u671f\u5f85\u3057\u305f\u914d\u5217\u306b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre><code>\/\/ NG: \u623b\u308a\u5024\u304c\u306a\u3044\r\nconst a = [1, 2, 3].map(n =&gt; {\r\n  n * 2;\r\n});\r\n\r\n\/\/ OK\r\nconst b = [1, 2, 3].map(n =&gt; {\r\n  return n * 2;\r\n});<\/code><\/pre>\n<h2>4. map\u306f\u526f\u4f5c\u7528\u3060\u3051\u306e\u305f\u3081\u306b\u4f7f\u308f\u306a\u3044<\/h2>\n<p>\u623b\u308a\u5024\u306e\u914d\u5217\u3092\u4f7f\u308f\u305a\u3001\u30ed\u30b0\u51fa\u529b\u3084\u5916\u90e8\u5909\u6570\u306e\u66f4\u65b0\u3060\u3051\u304c\u76ee\u7684\u306a\u3089map\u3088\u308aforEach\u306e\u65b9\u304c\u610f\u56f3\u3092\u8868\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002map\u306f\u300c\u5909\u63db\u7d50\u679c\u3092\u4f7f\u3046\u300d\u5834\u9762\u306b\u5bc4\u305b\u308b\u3068\u8aad\u307f\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u76ee\u7684<\/th>\n<th>\u5411\u3044\u3066\u3044\u308b\u65b9\u6cd5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5404\u8981\u7d20\u3092\u5225\u306e\u5024\u3078\u5909\u63db\u3059\u308b<\/td>\n<td>map<\/td>\n<\/tr>\n<tr>\n<td>\u6761\u4ef6\u306b\u5408\u3046\u8981\u7d20\u3092\u6b8b\u3059<\/td>\n<td>filter<\/td>\n<\/tr>\n<tr>\n<td>\u526f\u4f5c\u7528\u3092\u4f34\u3046\u53cd\u5fa9\u51e6\u7406\u3092\u884c\u3046<\/td>\n<td>forEach<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uff08filter\u3067\u6761\u4ef6\u306b\u5408\u3046\u8981\u7d20\u3092\u62bd\u51fa\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1058\/\">\u3010JavaScript\u5165\u9580\u3011filter\u95a2\u6570\u306e\u4f7f\u3044\u65b9\u3068\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc<\/a>\u300f\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<h2>5. parseInt\u3092map\u3078\u76f4\u63a5\u6e21\u3059\u3068\u304d\u306f\u5f15\u6570\u306b\u6ce8\u610f\u3059\u308b<\/h2>\n<p>map\u306f\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3078element\u3060\u3051\u3067\u306a\u304findex\u3082\u6e21\u3057\u307e\u3059\u3002parseInt\u306f\u7b2c2\u5f15\u6570\u3092\u57fa\u6570\u3068\u3057\u3066\u53d7\u3051\u53d6\u308b\u305f\u3081\u3001map(parseInt)\u306e\u3088\u3046\u306b\u76f4\u63a5\u6e21\u3059\u3068\u610f\u56f3\u3057\u306a\u3044\u7d50\u679c\u306b\u306a\u308a\u307e\u3059\u3002\u5909\u63db\u3057\u305f\u3044\u5024\u3060\u3051\u3092\u660e\u793a\u7684\u306b\u6e21\u3057\u307e\u3059\u3002<\/p>\n<pre><code>const values = [&#39;10&#39;, &#39;20&#39;, &#39;30&#39;];\r\nconst numbers = values.map(value =&gt; Number.parseInt(value, 10));<\/code><\/pre>\n<h2>6. map\u30e1\u30bd\u30c3\u30c9\u3068Map\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6df7\u540c\u3057\u306a\u3044<\/h2>\n<p>\u914d\u5217\u306emap\u30e1\u30bd\u30c3\u30c9\u306f\u914d\u5217\u5909\u63db\u306e\u305f\u3081\u306e\u95a2\u6570\u3067\u3059\u3002\u4e00\u65b9\u3001Map\u306f\u30ad\u30fc\u3068\u5024\u3092\u4fdd\u6301\u3059\u308b\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u3059\u3002\u540d\u524d\u306f\u540c\u3058\u3067\u3082\u7528\u9014\u304c\u7570\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\uff08\u914d\u5217\u30fbJSON\u30fbMap\u3092\u542b\u3080JavaScript\u30c7\u30fc\u30bf\u64cd\u4f5c\u306e\u5168\u4f53\u50cf\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/965\/\">JavaScript\u306e\u914d\u5217\u30fbJSON\u30fbmap\u30fbMap\uff1a\u30c7\u30fc\u30bf\u64cd\u4f5c\u8853<\/a>\u300f\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<h2>\u3088\u304f\u3042\u308b\u8cea\u554f<\/h2>\n<h3>map\u306f\u5143\u306e\u914d\u5217\u3092\u5909\u66f4\u3057\u307e\u3059\u304b\uff1f<\/h3>\n<p>map\u81ea\u4f53\u306f\u65b0\u3057\u3044\u914d\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u8981\u7d20\u304cobject\u3067\u3001\u305d\u306eobject\u81ea\u4f53\u3092\u76f4\u63a5\u5909\u66f4\u3059\u308c\u3070\u53c2\u7167\u5148\u306f\u5909\u308f\u308a\u5f97\u307e\u3059\u3002\u5fc5\u8981\u306a\u3089\u65b0\u3057\u3044object\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h3>map\u3067\u6761\u4ef6\u5206\u5c90\u3057\u3066\u8981\u7d20\u3092\u9664\u5916\u3067\u304d\u307e\u3059\u304b\uff1f<\/h3>\n<p>map\u306f\u57fa\u672c\u7684\u306b\u5165\u529b\u8981\u7d20\u3054\u3068\u306b\u7d50\u679c\u8981\u7d20\u3092\u4f5c\u308a\u307e\u3059\u3002\u9664\u5916\u304c\u76ee\u7684\u306a\u3089filter\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u65b9\u304c\u610f\u56f3\u3092\u8868\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081\uff1amap\u306f\u5909\u63db\u7d50\u679c\u3092\u4f7f\u3046\u3068\u304d\u306b\u9078\u3076<\/h2>\n<ul>\n<li>map\u306f\u65b0\u3057\u3044\u914d\u5217\u3092\u8fd4\u3059<\/li>\n<li>object\u914d\u5217\u306e\u6574\u5f62\u306b\u4f7f\u3044\u3084\u3059\u3044<\/li>\n<li>\u6ce2\u62ec\u5f27\u3092\u4f7f\u3046\u306a\u3089return\u3092\u5fd8\u308c\u306a\u3044<\/li>\n<li>\u526f\u4f5c\u7528\u3060\u3051\u306a\u3089forEach\u3092\u691c\u8a0e\u3059\u308b<\/li>\n<li>parseInt\u306a\u3069\u8907\u6570\u5f15\u6570\u3092\u53d6\u308b\u95a2\u6570\u306e\u76f4\u63a5\u6e21\u3057\u306b\u6ce8\u610f\u3059\u308b<\/li>\n<\/ul>\n<p>\u624b\u5143\u306efor\u30eb\u30fc\u30d7\u30921\u3064\u9078\u3073\u3001\u300c\u5404\u8981\u7d20\u3092\u5909\u63db\u3057\u3066\u65b0\u3057\u3044\u914d\u5217\u3092\u4f5c\u308b\u51e6\u7406\u300d\u306a\u3089map\u3078\u66f8\u304d\u63db\u3048\u3066\u52d5\u304d\u3092\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"featured_media":6377,"template":"","meta":{"ssp_meta_title":"JavaScript map\u306e\u4f7f\u3044\u65b9\uff5c\u914d\u5217\u5909\u63db\u30fbindex\u30fbobject\u5909\u63db\u3068\u6ce8\u610f\u70b9","ssp_meta_description":"JavaScript\u306eArray.prototype.map\u3092\u5b9f\u4f8b\u3067\u89e3\u8aac\u3002\u65b0\u3057\u3044\u914d\u5217\u3092\u8fd4\u3059\u4ed5\u7d44\u307f\u3001element\u30fbindex\u30fbarray\u5f15\u6570\u3001object\u914d\u5217\u306e\u5909\u63db\u3001forEach\u3068\u306e\u9055\u3044\u3001\u3088\u304f\u3042\u308b\u30df\u30b9\u307e\u3067\u6574\u7406\u3057\u307e\u3059\u3002","ssp_meta_keyword":"JavaScript map,map \u4f7f\u3044\u65b9,Array.prototype.map,JavaScript \u914d\u5217 \u5909\u63db,map index,map object,map forEach \u9055\u3044","ssp_meta_canonical":""},"route_category":[9],"_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/6372"}],"collection":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route"}],"about":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/types\/route"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media\/6377"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=6372"}],"wp:term":[{"taxonomy":"route_category","embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route_category?post=6372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}