{"id":6354,"date":"2026-04-17T14:49:27","date_gmt":"2026-04-17T05:49:27","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=6354"},"modified":"2026-09-17T14:49:36","modified_gmt":"2026-09-17T05:49:36","slug":"javascript-optional-chaining","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/6354\/","title":{"rendered":"JavaScript Optional Chaining\u306e\u4f7f\u3044\u65b9\uff5c?.\u3092\u4f7f\u3046\u5834\u6240\u30fb\u4f7f\u308f\u306a\u3044\u5834\u6240"},"content":{"rendered":"<p>\n  `Cannot read properties of undefined` \u3092\u6b62\u3081\u308b\u305f\u3081\u306b\u3001\u898b\u3064\u3051\u305f\u30d7\u30ed\u30d1\u30c6\u30a3\u3078\u7247\u3063\u7aef\u304b\u3089 `?.` \u3092\u4ed8\u3051\u3066\u3044\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002Optional Chaining\uff08\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u30c1\u30a7\u30fc\u30f3\uff09\u306f\u3001`null` \u3084 `undefined`<br \/>\n  \u306e\u53ef\u80fd\u6027\u304c\u3042\u308b\u5024\u3078\u5b89\u5168\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u305f\u3081\u306e\u4fbf\u5229\u306a\u69cb\u6587\u3067\u3059\u3002\u305f\u3060\u3057\u3001\u30a8\u30e9\u30fc\u3092\u51fa\u3055\u306a\u304f\u3059\u308b\u3053\u3068\u3068\u3001\u30b3\u30fc\u30c9\u304c\u6b63\u3057\u304f\u306a\u308b\u3053\u3068\u306f\u540c\u3058\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f `?.`<br \/>\n  \u306e\u66f8\u304d\u65b9\u3060\u3051\u3067\u306a\u304f\u3001\u300c\u6b20\u640d\u3092\u8a31\u5bb9\u3057\u3066\u3088\u3044\u5834\u6240\u304b\u300d\u3092\u57fa\u6e96\u306b\u3001\u4f7f\u3046\u5834\u6240\u30fb\u4f7f\u308f\u306a\u3044\u5834\u6240\u3092\u30b3\u30fc\u30c9\u3067\u6574\u7406\u3057\u307e\u3059\u3002\n<\/p>\n<h2>\u7d50\u8ad6\uff1a\u300c\u6b20\u640d\u3092\u8a31\u5bb9\u3057\u3066\u3088\u3044\u5834\u6240\u300d\u3067\u4f7f\u3046<\/h2>\n<p>\n  Optional Chaining\u3092\u4f7f\u3046\u304b\u8ff7\u3063\u305f\u3089\u3001\u6700\u521d\u306b\u78ba\u8a8d\u3057\u305f\u3044\u306e\u306f\u300c\u305d\u306e\u5024\u304c\u7121\u304f\u3066\u3082\u6b63\u5e38\u306a\u72b6\u614b\u3068\u8a00\u3048\u308b\u304b\u300d\u3067\u3059\u3002\u30e6\u30fc\u30b6\u30fc\u306e\u4efb\u610f\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3001\u5b58\u5728\u3057\u306a\u3044\u3053\u3068\u304c\u4ed5\u69d8\u4e0a\u3042\u308a\u5f97\u308bAPI\u9805\u76ee\u3001\u4efb\u610f\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306a\u3069\u306f `?.`<br \/>\n  \u3068\u76f8\u6027\u304c\u826f\u3044\u5bfe\u8c61\u3067\u3059\u3002\n<\/p>\n<table>\n<thead>\n<tr>\n<th>\u72b6\u6cc1<\/th>\n<th>\u304a\u3059\u3059\u3081<\/th>\n<th>\u7406\u7531<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u9014\u4e2d\u306e\u5024\u304c\u7121\u3044\u3053\u3068\u3092\u4ed5\u69d8\u3068\u3057\u3066\u8a31\u5bb9\u3059\u308b<\/td>\n<td>`?.` \u3092\u4f7f\u3046<\/td>\n<td>`null` \/ `undefined` \u3067\u5b89\u5168\u306b\u77ed\u7d61\u3057\u3001`undefined` \u3092\u8fd4\u305b\u308b<\/td>\n<\/tr>\n<tr>\n<td>\u672c\u6765\u5fc5\u9808\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u7121\u3044<\/td>\n<td>\u5165\u529b\u30fb\u72b6\u614b\u3092\u691c\u8a3c\u3059\u308b<\/td>\n<td>`?.` \u3067\u63e1\u308a\u3064\u3076\u3059\u3068\u3001\u672c\u6765\u306e\u4e0d\u5177\u5408\u306b\u6c17\u4ed8\u304d\u306b\u304f\u3044<\/td>\n<\/tr>\n<tr>\n<td>\u7121\u3044\u5834\u5408\u306e\u8868\u793a\u5024\u30fb\u65e2\u5b9a\u5024\u304c\u5fc5\u8981<\/td>\n<td>`?.` \u3068 `??` \u3092\u7d44\u307f\u5408\u308f\u305b\u308b<\/td>\n<td>\u6b20\u640d\u6642\u306e\u6319\u52d5\u3092\u660e\u793a\u3067\u304d\u308b<\/td>\n<\/tr>\n<tr>\n<td>\u5909\u6570\u81ea\u4f53\u304c\u5ba3\u8a00\u3055\u308c\u3066\u3044\u306a\u3044<\/td>\n<td>\u5ba3\u8a00\u30fb\u30b9\u30b3\u30fc\u30d7\u3092\u76f4\u3059<\/td>\n<td>`undeclaredVar?.prop` \u3067\u3082ReferenceError\u306b\u306a\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3064\u307e\u308a `?.` \u306f\u300c\u30a8\u30e9\u30fc\u3092\u6d88\u3059\u8a18\u53f7\u300d\u3067\u306f\u306a\u304f\u3001\u300c\u3053\u3053\u306f\u5024\u304c\u7121\u3044\u72b6\u614b\u3092\u8a31\u5bb9\u3059\u308b\u300d\u3068\u3044\u3046\u8a2d\u8a08\u610f\u56f3\u3092\u30b3\u30fc\u30c9\u306b\u8868\u3059\u305f\u3081\u306b\u4f7f\u3046\u3001\u3068\u8003\u3048\u308b\u3068\u5224\u65ad\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<hr \/>\n<h2>Optional Chaining\uff08?.\uff09\u3068\u306f<\/h2>\n<p>\n  Optional Chaining\uff08`?.`\uff09\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u53c2\u7167\u3084\u95a2\u6570\u547c\u3073\u51fa\u3057\u3092\u884c\u3046\u3068\u304d\u3001\u8a55\u4fa1\u5bfe\u8c61\u304c `null` \u307e\u305f\u306f `undefined` \u306a\u3089\u3001\u305d\u306e\u6642\u70b9\u3067\u51e6\u7406\u3092\u77ed\u7d61\u3057\u3066 `undefined` \u3092\u8fd4\u3059\u69cb\u6587\u3067\u3059\u3002ECMAScript<br \/>\n  2026\u4ed5\u69d8\u3067\u3082\u3001Optional Chain\u306e\u57fa\u5e95\u5024\u304c `undefined` \u307e\u305f\u306f `null` \u306e\u5834\u5408\u306f `undefined` \u3092\u8fd4\u3059\u3053\u3068\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\n<\/p>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1anullish<\/strong><br \/>JavaScript\u3067\u306f\u3001`null` \u307e\u305f\u306f `undefined` \u306e\u3069\u3061\u3089\u304b\u3067\u3042\u308b\u72b6\u614b\u3092\u307e\u3068\u3081\u3066nullish\u3068\u547c\u3073\u307e\u3059\u3002Optional Chaining\u304c\u77ed\u7d61\u3059\u308b\u306e\u306f\u3001\u3053\u306e2\u7a2e\u985e\u3067\u3059\u3002<\/p>\n<\/blockquote>\n<pre><code>const user = {};\r\n\r\n\/\/ profile\u304c\u306a\u3044\u305f\u3081TypeError\r\n\/\/ console.log(user.profile.name);\r\n\r\nconst name = user.profile?.name;\r\nconsole.log(name); \/\/ undefined<\/code><\/pre>\n<p>`user.profile?.name` \u3067\u306f\u3001`profile` \u304c `undefined` \u306a\u306e\u3067 `.name` \u3078\u9032\u307e\u305a\u3001\u5f0f\u5168\u4f53\u304c `undefined` \u306b\u306a\u308a\u307e\u3059\u3002`false`\u3001`0`\u3001\u7a7a\u6587\u5b57\u5217\u306e\u3088\u3046\u306a\u5024\u307e\u3067\u6b20\u640d\u6271\u3044\u3059\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\n  \uff08Cannot read properties\u7cfb\u306e\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u308b\u539f\u56e0\u304b\u3089\u5207\u308a\u5206\u3051\u305f\u3044\u5834\u5408\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1312\/\"\n    >TypeError: Cannot read property \u2018xxx\u2019 of undefined \u306e\u539f\u56e0\u3068\u5bfe\u51e6\u6cd5\u3092\u5fb9\u5e95\u89e3\u8aac\u3010\u521d\u5fc3\u8005\u5411\u3051\u3011<\/a\n  >\u300f\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n<\/p>\n<hr \/>\n<h2>\u30d7\u30ed\u30d1\u30c6\u30a3\u30fb\u914d\u5217\u30fb\u95a2\u6570\u3067\u306e\u4f7f\u3044\u65b9<\/h2>\n<p>`?.` \u306f\u3001\u901a\u5e38\u306e\u30c9\u30c3\u30c8\u8a18\u6cd5\u3060\u3051\u3067\u306a\u304f\u3001\u914d\u5217\u3084\u52d5\u7684\u30ad\u30fc\u306e\u30d6\u30e9\u30b1\u30c3\u30c8\u8a18\u6cd5\u3001\u4efb\u610f\u306e\u95a2\u6570\u547c\u3073\u51fa\u3057\u306b\u3082\u4f7f\u3048\u307e\u3059\u3002\u307e\u305a\u306f\u300c\u5024\u304c\u7121\u3044\u3053\u3068\u304c\u4ed5\u69d8\u4e0a\u3042\u308a\u5f97\u308b\u5834\u6240\u300d\u306b\u9650\u5b9a\u3057\u3066\u4f7f\u3046\u306e\u304c\u5b89\u5168\u3067\u3059\u3002<\/p>\n<pre><code>\/\/ 1. \u30d7\u30ed\u30d1\u30c6\u30a3\r\nconst city = user.address?.city;\r\n\r\n\/\/ 2. \u914d\u5217\u30fb\u52d5\u7684\u30ad\u30fc\r\nconst firstItem = response.items?.[0];\r\nconst key = &quot;theme&quot;;\r\nconst theme = settings?.[key];\r\n\r\n\/\/ 3. \u4efb\u610f\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\r\nonSuccess?.(result);<\/code><\/pre>\n<p>\n  \u95a2\u6570\u547c\u3073\u51fa\u3057\u3067\u306f\u3001\u5bfe\u8c61\u306e\u95a2\u6570\u304c\u5b58\u5728\u3057\u306a\u3051\u308c\u3070 `undefined` \u304c\u8fd4\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u81ea\u4f53\u306f\u5b58\u5728\u3059\u308b\u3082\u306e\u306e\u5024\u304c\u95a2\u6570\u3067\u306f\u306a\u3044\u5834\u5408\u3001`callback?.()` \u3068\u3057\u3066\u3082 `TypeError`<br \/>\n  \u306b\u306a\u308a\u307e\u3059\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5074\u3082\u6b20\u640d\u3057\u5f97\u308b\u306a\u3089 `service?.run?.()` \u306e\u3088\u3046\u306b\u3001\u305d\u308c\u305e\u308c\u306e\u5883\u754c\u3092\u5206\u3051\u3066\u8003\u3048\u307e\u3059\u3002\n<\/p>\n<hr \/>\n<h2>??\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u65e2\u5b9a\u5024\u3092\u6c7a\u3081\u308b<\/h2>\n<p>Optional Chaining\u3067\u5f97\u3089\u308c\u308b\u5024\u306f\u3001\u9014\u4e2d\u304c\u6b20\u640d\u3057\u3066\u3044\u308c\u3070 `undefined` \u306b\u306a\u308a\u307e\u3059\u3002\u753b\u9762\u8868\u793a\u306a\u3069\u3067\u65e2\u5b9a\u5024\u304c\u5fc5\u8981\u306a\u3089\u3001Nullish Coalescing\u6f14\u7b97\u5b50\uff08`??`\uff09\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u610f\u56f3\u3092\u660e\u78ba\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>const city = user.address?.city ?? &quot;\u672a\u8a2d\u5b9a&quot;;\r\nconst firstName = users?.[0]?.name ?? &quot;\u8a72\u5f53\u30e6\u30fc\u30b6\u30fc\u306a\u3057&quot;;<\/code><\/pre>\n<p>\n  `??` \u304c\u53f3\u8fba\u3078\u5207\u308a\u66ff\u308f\u308b\u306e\u306f `null` \u307e\u305f\u306f `undefined` \u306e\u3068\u304d\u3060\u3051\u3067\u3059\u3002`||` \u306f `0`\u3001`false`\u3001\u7a7a\u6587\u5b57\u5217\u3082\u507d\u5024\u3068\u3057\u3066\u53f3\u8fba\u3078\u5207\u308a\u66ff\u3048\u308b\u305f\u3081\u30010\u4ef6\u3084\u7a7a\u6587\u5b57\u5217\u3092\u6709\u52b9\u5024\u3068\u3057\u3066\u6b8b\u3057\u305f\u3044\u5834\u9762\u3067\u306f\u6319\u52d5\u304c\u7570\u306a\u308a\u307e\u3059\u3002\n<\/p>\n<h2>\u4f7f\u3044\u3059\u304e\u308b\u3068\u30d0\u30b0\u3092\u96a0\u3059\uff1a?.\u3092\u4f7f\u308f\u306a\u3044\u65b9\u304c\u3088\u3044\u5834\u9762<\/h2>\n<p>\n  \u4e00\u756a\u6ce8\u610f\u3057\u305f\u3044\u306e\u306f\u3001\u672c\u6765\u5fc5\u9808\u306e\u30c7\u30fc\u30bf\u306b `?.` \u3092\u91cd\u306d\u3066\u300c\u30a8\u30e9\u30fc\u3060\u3051\u6d88\u3059\u300d\u4f7f\u3044\u65b9\u3067\u3059\u3002\u305f\u3068\u3048\u3070\u6ce8\u6587\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5fc5\u9808\u306a\u306e\u306b\u3001`order?.items?.`<br \/>\n  \u3068\u66f8\u3051\u3070\u7570\u5e38\u306a\u72b6\u614b\u3067\u3082\u51e6\u7406\u304c\u9759\u304b\u306b\u9032\u307f\u307e\u3059\u3002\u7d50\u679c\u3068\u3057\u3066\u3001\u539f\u56e0\u306e\u767a\u898b\u304c\u9045\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<pre><code>\/\/ \u60aa\u3044\u4f8b\uff1aorder\u81ea\u4f53\u304c\u5fc5\u9808\u306a\u306e\u306b\u6b20\u640d\u3092\u8a31\u5bb9\u3057\u3066\u3057\u307e\u3046\r\nconst total = order?.items?.reduce(\r\n  (sum, item) =&gt; sum + item.price,\r\n  0\r\n);\r\n\r\n\/\/ \u6539\u5584\u4f8b\uff1a\u5fc5\u9808\u5024\u306f\u5148\u306b\u691c\u8a3c\u3059\u308b\r\nif (!order) {\r\n  throw new Error(&quot;order is required&quot;);\r\n}\r\n\r\nconst total = order.items?.reduce(\r\n  (sum, item) =&gt; sum + item.price,\r\n  0\r\n) ?? 0;<\/code><\/pre>\n<ul>\n<li>API\u5951\u7d04\u3067\u5fc5\u9808\u3068\u3055\u308c\u3066\u3044\u308b\u30ec\u30b9\u30dd\u30f3\u30b9\u9805\u76ee<\/li>\n<li>\u30a2\u30d7\u30ea\u8d77\u52d5\u306b\u5fc5\u8981\u306a\u8a2d\u5b9a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/li>\n<li>\u72b6\u614b\u7ba1\u7406\u4e0a\u3001\u5b58\u5728\u3057\u306a\u3044\u3068\u8a2d\u8a08\u9055\u53cd\u306b\u306a\u308b\u5024<\/li>\n<li>\u5fc5\u9808\u30d5\u30a9\u30fc\u30e0\u5024\u3084\u5fc5\u9808\u30eb\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf<\/li>\n<\/ul>\n<p>\n  \u3053\u3046\u3057\u305f\u5024\u306f\u3001\u4f7f\u7528\u5730\u70b9\u3067 `?.` \u3092\u8ffd\u52a0\u3059\u308b\u3088\u308a\u3001\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308b\u5883\u754c\u3067\u691c\u8a3c\u3059\u308b\u65b9\u304c\u539f\u56e0\u3092\u8ffd\u3044\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002Optional<br \/>\n  Chaining\u306f\u300c\u6b20\u640d\u3057\u3066\u3088\u3044\u5024\u300d\u306e\u305f\u3081\u306b\u6b8b\u3057\u3066\u304a\u304f\u3068\u3001\u30b3\u30fc\u30c9\u304b\u3089\u8a2d\u8a08\u610f\u56f3\u3082\u8aad\u307f\u53d6\u308a\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002\n<\/p>\n<p>\n  \uff08\u305d\u3082\u305d\u3082undefined\u304c\u3069\u3053\u3067\u751f\u307e\u308c\u3066\u3044\u308b\u304b\u3092\u30c7\u30d0\u30c3\u30b0\u3057\u305f\u3044\u5834\u5408\u306b\u3064\u3044\u3066\u306f\u300e<a href=\"https:\/\/route-zero.com\/recruit\/route\/1340\/\"\n    >\u306a\u305c\u300cundefined\u300d\u304c\u51fa\u308b\uff1f\u539f\u56e0\u3068\u89e3\u6c7a\u6cd510\u9078\uff5cJavaScript \u306e\u30c7\u30d0\u30c3\u30b0\u306b\u52b9\u304f\u5b9f\u4f8b\u96c6<\/a\n  >\u300f\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\n<\/p>\n<h2>?.\u3067\u3082\u9632\u3052\u306a\u3044\u30b1\u30fc\u30b9<\/h2>\n<p>`?.` \u3092\u4ed8\u3051\u308c\u3070\u3001\u3069\u3093\u306aTypeError\u3084ReferenceError\u3082\u9632\u3052\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u7279\u306b\u6b21\u306e4\u3064\u306f\u3001\u5b9f\u52d9\u3067\u300c?.\u3092\u4ed8\u3051\u305f\u306e\u306b\u843d\u3061\u308b\u300d\u539f\u56e0\u306b\u306a\u308a\u3084\u3059\u3044\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u30b1\u30fc\u30b9<\/th>\n<th>\u30b3\u30fc\u30c9\u4f8b<\/th>\n<th>\u7d50\u679c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u672a\u5ba3\u8a00\u306e\u5909\u6570<\/td>\n<td>`undeclaredVar?.prop`<\/td>\n<td>ReferenceError\u3002Optional Chaining\u306f\u672a\u5ba3\u8a00\u30eb\u30fc\u30c8\u3092\u4f5c\u3089\u306a\u3044<\/td>\n<\/tr>\n<tr>\n<td>\u5b58\u5728\u3059\u308b\u304c\u95a2\u6570\u3067\u306f\u306a\u3044<\/td>\n<td>`obj.method?.()`<\/td>\n<td>`method`\u304c\u975e\u95a2\u6570\u306a\u3089TypeError<\/td>\n<\/tr>\n<tr>\n<td>\u30c1\u30a7\u30fc\u30f3\u9014\u4e2d\u3092\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0<\/td>\n<td>`(user?.profile).name`<\/td>\n<td>`user`\u304cnullish\u306a\u3089\u3001\u305d\u306e\u5f8c\u306e`.name`\u3067TypeError\u306b\u306a\u308a\u5f97\u308b<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u5165\u5148\u3068\u3057\u3066\u4f7f\u3046<\/td>\n<td>`obj?.prop = 1`<\/td>\n<td>SyntaxError\u3002Optional Chain\u306e\u8a55\u4fa1\u7d50\u679c\u306b\u306f\u4ee3\u5165\u3067\u304d\u306a\u3044<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre><code>const user = null;\r\n\r\n\/\/ \u9023\u7d9a\u3057\u305f\u30c1\u30a7\u30fc\u30f3\u306a\u3089\u77ed\u7d61\u3059\u308b\r\nconst safeName = user?.profile?.name;\r\n\r\n\/\/ \u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\u3059\u308b\u3068\u3001\u305d\u306e\u5f8c\u306e .name \u306f\u5225\u8a55\u4fa1\u306b\u306a\u308b\r\n\/\/ const unsafeName = (user?.profile).name; \/\/ TypeError<\/code><\/pre>\n<p>\n  MDN\u3067\u306f\u3001`new Intl?.DateTimeFormat()` \u306e\u3088\u3046\u306b `new` \u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\u90e8\u5206\u3078Optional Chaining\u3092\u4f7f\u3046\u69cb\u6587\u3084\u3001\u30bf\u30b0\u4ed8\u304d\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3078\u4f7f\u3046\u69cb\u6587\u3082\u7121\u52b9\u3068\u3055\u308c\u3066\u3044\u307e\u3059\u3002`?.`<br \/>\n  \u306f\u300c\u30d7\u30ed\u30d1\u30c6\u30a3\u53c2\u7167\u30fb\u30d6\u30e9\u30b1\u30c3\u30c8\u30a2\u30af\u30bb\u30b9\u30fb\u95a2\u6570\u547c\u3073\u51fa\u3057\u306a\u3089\u4f55\u3067\u3082\u7f6e\u3051\u308b\u8a18\u53f7\u300d\u3067\u306f\u306a\u3044\u70b9\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n<\/p>\n<h2>\u5b9f\u52d9\u3067\u8ff7\u308f\u306a\u3044\u5224\u65ad\u30d5\u30ed\u30fc<\/h2>\n<p>\u30b3\u30fc\u30c9\u30ec\u30d3\u30e5\u30fc\u3067 `?.` \u306e\u59a5\u5f53\u6027\u3092\u5224\u65ad\u3059\u308b\u3068\u304d\u306f\u3001\u69cb\u6587\u304b\u3089\u898b\u308b\u3088\u308a\u3001\u5024\u306e\u5951\u7d04\u304b\u3089\u9006\u7b97\u3059\u308b\u3068\u8ff7\u3044\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>1. \u305d\u306e\u5024\u306f\u7121\u304f\u3066\u3082\u6b63\u5e38\u304b\u3002YES\u306a\u3089 `?.` \u306e\u5019\u88dc\u306b\u3059\u308b<\/li>\n<li>2. \u7121\u3044\u3053\u3068\u81ea\u4f53\u304c\u7570\u5e38\u304b\u3002YES\u306a\u3089\u3001`?.` \u3067\u306f\u306a\u304f\u5165\u529b\u30fb\u72b6\u614b\u3092\u5148\u306b\u691c\u8a3c\u3059\u308b<\/li>\n<li>3. \u6b20\u640d\u6642\u306b\u8868\u793a\u5024\u3084\u65e2\u5b9a\u5024\u304c\u5fc5\u8981\u304b\u3002\u5fc5\u8981\u306a\u3089 `?.` \u306e\u5f8c\u308d\u3078 `??` \u3092\u4ed8\u3051\u308b<\/li>\n<li>4. `?.` \u3092\u8ffd\u52a0\u3057\u3066\u30a8\u30e9\u30fc\u304c\u6d88\u3048\u305f\u5f8c\u3001\u306a\u305cnullish\u306b\u306a\u3063\u305f\u304b\u3092\u8aac\u660e\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3059\u308b<\/li>\n<li>5. \u30c1\u30a7\u30fc\u30f3\u304c\u9577\u3044\u5834\u5408\u306f\u3001\u3069\u306e\u6bb5\u968e\u307e\u3067\u6b20\u640d\u3092\u8a31\u5bb9\u3059\u308b\u4ed5\u69d8\u306a\u306e\u304b\u3092\u660e\u78ba\u306b\u3059\u308b<\/li>\n<\/ul>\n<p>\n  \u305f\u3068\u3048\u3070 `user?.company?.address?.city` \u304c\u52d5\u304f\u3053\u3068\u3068\u3001`user`\u30fb`company`\u30fb`address` \u306e\u3059\u3079\u3066\u304c\u4efb\u610f\u3067\u3088\u3044\u3053\u3068\u306f\u5225\u554f\u984c\u3067\u3059\u3002\u4ed5\u69d8\u4e0a\u4efb\u610f\u306a\u306e\u304c `address` \u3060\u3051\u306a\u3089\u3001\u4e0a\u6d41\u3067 `user` \u3068 `company`<br \/>\n  \u3092\u4fdd\u8a3c\u3057\u305f\u3046\u3048\u3067 `user.company.address?.city` \u3068\u3057\u305f\u65b9\u304c\u3001\u7570\u5e38\u3068\u8a31\u5bb9\u53ef\u80fd\u306a\u6b20\u640d\u3092\u533a\u5225\u3067\u304d\u307e\u3059\u3002\n<\/p>\n<h2>\u307e\u3068\u3081\uff1a?.\u306f\u30a8\u30e9\u30fc\u3092\u6d88\u3059\u9053\u5177\u3067\u306f\u306a\u304f\u300c\u6b20\u640d\u3092\u8a31\u5bb9\u3059\u308b\u300d\u5ba3\u8a00<\/h2>\n<ul>\n<li>Optional Chaining\u306f\u3001\u5bfe\u8c61\u304c`null`\u307e\u305f\u306f`undefined`\u306a\u3089\u77ed\u7d61\u3057\u3066`undefined`\u3092\u8fd4\u3059<\/li>\n<li>`obj?.prop`\u3001`obj?.[expr]`\u3001`func?.()`\u306e3\u30d1\u30bf\u30fc\u30f3\u3092\u57fa\u672c\u3068\u3057\u3066\u899a\u3048\u308b<\/li>\n<li>\u6b20\u640d\u6642\u306e\u65e2\u5b9a\u5024\u304c\u5fc5\u8981\u306a\u3089`??`\u3068\u7d44\u307f\u5408\u308f\u305b\u308b<\/li>\n<li>\u5fc5\u9808\u30c7\u30fc\u30bf\u306b`?.`\u3092\u91cd\u306d\u308b\u3068\u3001\u30a8\u30e9\u30fc\u306f\u6d88\u3048\u3066\u3082\u4e0d\u5177\u5408\u306e\u539f\u56e0\u3092\u96a0\u3059\u53ef\u80fd\u6027\u304c\u3042\u308b<\/li>\n<li>\u672a\u5ba3\u8a00\u5909\u6570\u3001\u975e\u95a2\u6570\u547c\u3073\u51fa\u3057\u3001\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\u3001\u7121\u52b9\u306a\u4ee3\u5165\u306a\u3069\u306f`?.`\u3067\u3082\u89e3\u6c7a\u3057\u306a\u3044<\/li>\n<\/ul>\n<p>\n  `Cannot read properties of undefined` \u306b\u906d\u9047\u3057\u305f\u3089\u3001\u307e\u305a\u300c\u3053\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u672c\u5f53\u306b\u4efb\u610f\u306a\u306e\u304b\u300d\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4efb\u610f\u306a\u3089 `?.`\u3001\u5fc5\u9808\u306a\u3089\u4e0a\u6d41\u306e\u30c7\u30fc\u30bf\u3084\u72b6\u614b\u3092\u76f4\u3059\u3002\u3053\u306e\u5206\u3051\u65b9\u3092\u5148\u306b\u6c7a\u3081\u308b\u3068\u3001Optional<br \/>\n  Chaining\u3092\u4fbf\u5229\u306b\u4f7f\u3044\u306a\u304c\u3089\u3001\u30a8\u30e9\u30fc\u306e\u539f\u56e0\u307e\u3067\u96a0\u3057\u3066\u3057\u307e\u3046\u30b3\u30fc\u30c9\u3092\u6e1b\u3089\u305b\u307e\u3059\u3002<\/p>\n","protected":false},"featured_media":6356,"template":"","meta":{"ssp_meta_title":"JavaScript Optional Chaining\uff08?.\uff09\u3068\u306f\uff1f\u4f7f\u3044\u65b9\u3068\u6ce8\u610f\u70b9","ssp_meta_description":"JavaScript\u306eOptional Chaining\uff08?.\uff09\u3092\u3001undefined\u30a8\u30e9\u30fc\u3092\u9632\u3050\u30b3\u30fc\u30c9\u4f8b\u304b\u3089\u89e3\u8aac\u3002\u30d7\u30ed\u30d1\u30c6\u30a3\u30fb\u914d\u5217\u30fb\u95a2\u6570\u30fb??\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u3001\u4f7f\u3044\u3059\u304e\u3067\u30d0\u30b0\u3092\u96a0\u3059\u30b1\u30fc\u30b9\u3001\u4f7f\u308f\u306a\u3044\u65b9\u304c\u3088\u3044\u5834\u9762\u307e\u3067\u5b9f\u52d9\u76ee\u7dda\u3067\u6574\u7406\u3057\u307e\u3059\u3002","ssp_meta_keyword":"JavaScript optional chaining,Optional Chaining ?.,JavaScript ?.,Cannot read properties of undefined,JavaScript undefined,optional chaining \u6ce8\u610f\u70b9,optional chaining \u4f7f\u3044\u3059\u304e,nullish coalescing ??","ssp_meta_canonical":""},"route_category":[9],"_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/6354"}],"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\/6356"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=6354"}],"wp:term":[{"taxonomy":"route_category","embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route_category?post=6354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}