{"id":4128,"date":"2019-05-02T13:02:04","date_gmt":"2019-05-02T04:02:04","guid":{"rendered":"https:\/\/greentown.tokyo\/?p=4128"},"modified":"2019-05-02T23:56:25","modified_gmt":"2019-05-02T14:56:25","slug":"es2018","status":"publish","type":"post","link":"https:\/\/greentown.tokyo\/?p=4128","title":{"rendered":"ES2018"},"content":{"rendered":"<p>\u3048\u30fc\u3001GW\u3072\u3068\u308a\u3082\u304f\u3082\u304f\u4f1a\u958b\u50ac\u4e2d\u3067\u3059\u3002<\/p>\n<p>\u307e\u3060React\u307e\u3067\u305f\u3069\u308a\u7740\u3051\u3066\u3044\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u304a\u53cb\u9054\u306b\u6559\u3048\u3066\u3082\u3089\u3063\u305f\u3053\u306e\u672c\u304c\u7d20\u6674\u3089\u3057\u3044\uff01<\/p>\n<p><a href=\"https:\/\/oukayuka.booth.pm\/items\/1312652\">https:\/\/oukayuka.booth.pm\/items\/1312652<\/a><\/p>\n<p><a href=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-4130\" src=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-300x300.png 300w, https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-150x150.png 150w, https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-768x766.png 768w, https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-100x100.png 100w, https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-400x400.png 400w, https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8-60x60.png 60w, https:\/\/greentown.tokyo\/wp-content\/uploads\/2019\/05\/b58a45d3559cc75109305d27be6d5ea8.png 1012w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>ES2018\u306e\u89e3\u8aac\u304c\u308f\u304b\u308a\u3084\u3059\u3044\uff01\uff08ES2018\u306e\u7ae0\u307e\u3067\u5b9f\u8df5\u3057\u305f\uff01\uff09<\/p>\n<p><a href=\"https:\/\/qiita.com\/shibukawa\/items\/19ab5c381bbb2e09d0d9\">https:\/\/qiita.com\/shibukawa\/items\/19ab5c381bbb2e09d0d9<\/a><\/p>\n<p>\u2191\u3053\u306e\u8a18\u4e8b\u3068\u4f75\u7528\u3057\u3066\u304a\u52c9\u5f37\u4e2d\u3067\u3059\u3002<\/p>\n<h2>ES2018<\/h2>\n<p>ES6\u3082\u542b\u3081\u304a\u3055\u3089\u3044\u3002<\/p>\n<h3>\u5909\u6570\u5ba3\u8a00<\/h3>\n<ul>\n<li>var\u306f\u4f7f\u308f\u306a\u3044\uff08\u7981\u6b62\u30ec\u30d9\u30eb\uff09\uff08\u95a2\u6570\u30b9\u30b3\u30fc\u30d7\uff09<\/li>\n<li>var \u3067\u5b9a\u7fa9\u3055\u308c\u305f\u5909\u6570\u306e<strong>\u30b9\u30b3\u30fc\u30d7\u306f\u95a2\u6570\u5358\u4f4d<\/strong>\u3001\u5236\u5fa1\u6587\u306e\u30d6\u30ed\u30c3\u30af\u306f\u3059\u308a\u629c\u3051\u308b<\/li>\n<li>\u591a\u6570\u306e\u8a00\u8a9e\u306e\u5909\u6570\u30b9\u30b3\u30fc\u30d7\u306f\u30d6\u30ed\u30c3\u30af\u5358\u4f4d\u306a\u306e\u3067\u3001\u305d\u306e\u30c6\u30a4\u3067var\u4f7f\u3046\u3068\u5371\u967a<\/li>\n<li>\u4ee3\u5165\u4e0d\u8981\u306a\u3082\u306e\u306f const \u4f7f\u3046\uff08\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\uff09<\/li>\n<li>\u3069\u3046\u3057\u3066\u3082\u518d\u4ee3\u5165\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f let \u3092\u4f7f\u3046\uff08\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\uff09<\/li>\n<\/ul>\n<h3>\u30a2\u30ed\u30fc\u95a2\u6570<\/h3>\n<ul>\n<li>function\u5ba3\u8a00\u3068\u30a2\u30ed\u30fc\u5f0f\u3067\u306fthis\u306e\u6319\u52d5\u304c\u7570\u306a\u308b<\/li>\n<li>function\u306f\u3001\u3059\u3050\u524d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u306a\u3044\u5834\u5408\u30b0\u30ed\u30fc\u30d0\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304cthis\u306b\u306a\u308b\u3001\u30a2\u30ed\u30fc\u95a2\u6570\u306f\u305d\u308c\u81ea\u8eab\u304cthis\u306b\u306a\u308b<\/li>\n<li>function\u306f\u5207\u308a\u6368\u3066\u307e\u3057\u3087\u3046\uff08\u95c7\u306b\u846c\u308b\uff09<\/li>\n<\/ul>\n<pre class=\"lang:js decode:true \">\/\/ \u30c0\u30e1\u4f8b\r\nfunction name(\u5f15\u6570) {\r\n     \u672c\u4f53\r\n}\r\n\r\n\/\/ \u3053\u3063\u3061\u4f7f\u3046\r\nconst name = (\u5f15\u6570) =&gt; {\r\n     \u672c\u4f53\r\n};<\/pre>\n<h3>\u95a2\u6570\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5f15\u6570\u304c\u4f7f\u3048\u308b<\/h3>\n<p>const sampleFunc = (<span style=\"color: #0000ff;\"><strong>n = 0<\/strong><\/span>) =&gt; n + 1;<\/p>\n<h6>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3082\u30c7\u30d5\u30a9\u30eb\u30c8\u3092\u8a2d\u5b9a\u3057\u3066\u4f3c\u305f\u3088\u3046\u306a\u3053\u3068\u304c\u3067\u304d\u308b<\/h6>\n<pre class=\"lang:js decode:true \">const thinking = {\r\n     name: \"Mikke\",\r\n     mind: \"GoLang\u3068\u622f\u308c\u305f\u3044\",\r\n     reason: \"`so` \u3060\u304b\u3089\"\r\n};\r\n \r\nconst { name=\"\u6211\u8f29\", mind, reason } = thinking;\r\nconsole.log(`${name}\u306f${reason} ${mind}\u3067\u3059`);<\/pre>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ node collection.js \r\nMikke\u306f`so` \u3060\u304b\u3089 GoLang\u3068\u622f\u308c\u305f\u3044\u3067\u3059<\/pre>\n<h3>\u30b7\u30e7\u30fc\u30c8\u30cf\u30f3\u30c9<\/h3>\n<pre class=\"lang:js decode:true \">const foo = 12345;\r\nconst obj = { foo, bar:678 };\r\nconsole.log(obj);<\/pre>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ node shorthand.js \r\n{ foo: 12345, bar: 678 }<\/pre>\n<h3>\u30af\u30e9\u30b9\u306e\u7d99\u627f<\/h3>\n<ul>\n<li>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f\u7d99\u627f\u3055\u308c\u306a\u3044\u306e\u3067\u3001\u7d99\u627f\u3057\u305f\u3089\u660e\u793a\u7684\u306b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3092\u66f8\u304f\u5fc5\u8981\u304c\u3042\u308b<\/li>\n<\/ul>\n<h3>Template literals &#8211; \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb<\/h3>\n<ul>\n<li>\u6587\u5b57\u5217\u3092&#8221;\u3068\u304b&#8217; \u3067\u306f\u306a\u304f ` \u3067 ${\u5909\u6570\u540d}\u3092\u304f\u304f\u308b\u3068\u3001\u5024\u3092\u5c55\u958b\u3057\u3066\u304f\u308c\u308b<\/li>\n<li>\uff0b\u3067\u7d50\u5408\u3068\u304b\u53e4\u3044\u30fb\u30fb<\/li>\n<\/ul>\n<h3>Destructuring Assignment &#8211; \u5206\u5272\u4ee3\u5165<\/h3>\n<pre class=\"lang:js decode:true \">const [n, m] = [1, 2];\r\nconsole.log(n, m);\r\n \r\nconst obj = { name: 'Mikke', hight:141 };\r\nconst { name, hight } = obj;\r\nconsole.log(name, hight);<\/pre>\n<p>React\u306e\u3070\u3042\u3044\u3001 const name = obj.name\u3063\u3066\u3084\u308b\u3068\u30a8\u30e9\u30fc<\/p>\n<h3>\u30b9\u30d7\u30ec\u30c3\u30c9\u6f14\u7b97\u5b50<\/h3>\n<pre class=\"lang:js decode:true\">const ary1 = ['A','B','C'];\r\nconst ary2 = [...ary1, 'D','E'];\r\nconsole.log(ary2);\r\n \r\nconst obj1 = {a:1, b:2, c:3};\r\nconst obj2 = {...obj1, d:4,e:5};\r\nconsole.log(obj2);<\/pre>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ node collection.js \r\n[ 'A', 'B', 'C', 'D', 'E' ]\r\n{ a: 1, b: 2, c: 3, d: 4, e: 5 }<\/pre>\n<h3>\u975e\u540c\u671f\u51e6\u7406<\/h3>\n<h6>JS\u306f\u524d\u306e\u51e6\u7406\u5f85\u305f\u305a\u306b\u6b21\u3078\u9032\u3093\u3058\u3083\u3046<\/h6>\n<pre class=\"lang:js decode:true\">const greeting = am =&gt; {\r\n     setTimeout(() =&gt; { console.log('\u8d77\u304d\u307e\u3057\u3087\u3046') }, am);\r\n};\r\n \r\nconst greet = () =&gt; {\r\n     console.log('\u304a\u3084\u3059\u307f\u306d\uff1f');\r\n     greeting(2000);\r\n     console.log('\u304a\u306f\u304a');\r\n};\r\n \r\ngreet();\r\n<\/pre>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ node sync-test.js \r\n\u304a\u3084\u3059\u307f\u306d\uff1f\r\n\u304a\u306f\u304a\r\n\u8d77\u304d\u307e\u3057\u3087\u3046<\/pre>\n<p>\u8d77\u304d\u307e\u3057\u3087\u3046\u3001\u304a\u306f\u304a\u3001\u306e\u9806\u3067\u5b9f\u884c\u3055\u308c\u305f\u3044\u306e\u301c<\/p>\n<h6>\u975e\u540c\u671f\u51e6\u7406 &#8211; Promises\u69cb\u6587<\/h6>\n<pre class=\"lang:js decode:true \">const sleep = am =&gt; new Promise(resolve =&gt; setTimeout(resolve, am));\r\n \r\nconst greet = () =&gt; {\r\n     console.log('\u304a\u3084\u3059\u307f\u306d\uff1f');\r\n     \/\/greeting(2000);\r\n     sleep(2000)\r\n         .then(() =&gt; {\r\n           console.log('\u8d77\u304d\u307e\u3057\u3087\u3046');\r\n           console.log('\u304a\u306f\u304a');\r\n     })\r\n     .catch(err =&gt; {\r\n       console.error('error!:', err);\r\n     })\r\n};\r\n \r\ngreet();<\/pre>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ node sync-test.js \r\n\u304a\u3084\u3059\u307f\u306d\uff1f\r\n\u8d77\u304d\u307e\u3057\u3087\u3046\r\n\u304a\u306f\u304a<\/pre>\n<p>Promise\u95a2\u6570\u306e\u66f8\u304d\u65b9\u304c\u3044\u307e\u3044\u3061\u308f\u304b\u3089\u3093\u3002\u3002<\/p>\n<h6>\u975e\u540c\u671f\u51e6\u7406 &#8211; async\/await\uff08\u30a8\u30a4\u30b7\u30f3\u30af\u30fb\u30a2\u30a6\u30a7\u30a4\u30c8\uff09<\/h6>\n<pre class=\"lang:default decode:true \">const sleep = am =&gt; new Promise(resolve =&gt; setTimeout(resolve, am));\r\n \r\nconst greet = async () =&gt; {\r\n     console.log('\u304a\u3084\u3059\u307f\u306d\uff1f');\r\n     \/\/greeting(2000);\r\n     try {\r\n       await sleep(2000);\r\n       console.log('\u8d77\u304d\u307e\u3057\u3087\u3046');\r\n       console.log('\u304a\u306f\u304a');\r\n     } catch (err) {\r\n       console.error('error!:', err);\r\n     }\r\n};\r\n \r\ngreet();<\/pre>\n<pre class=\"theme:dark-terminal lang:default decode:true \">$ node sync-test.js \r\n\u304a\u3084\u3059\u307f\u306d\uff1f\r\n\u8d77\u304d\u307e\u3057\u3087\u3046\r\n\u304a\u306f\u304a<\/pre>\n<p>\u75b2\u308c\u305f\u301c\u3002GW\u524d\u534a\u7d42\u4e86\u3057\u3061\u3083\u3046\u301c\u30fb\u30fbGO\u3082\u3084\u308a\u305f\u3044\u301c<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3048\u30fc\u3001GW\u3072\u3068\u308a\u3082\u304f\u3082\u304f\u4f1a\u958b\u50ac\u4e2d\u3067\u3059\u3002 \u307e\u3060React\u307e\u3067\u305f\u3069\u308a\u7740\u3051\u3066\u3044\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u304a\u53cb\u9054\u306b\u6559\u3048\u3066\u3082\u3089\u3063\u305f\u3053\u306e\u672c\u304c\u7d20\u6674\u3089\u3057\u3044\uff01 https:\/\/oukayuka.booth.pm\/items\/131 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":4130,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79,1,97],"tags":[],"class_list":["post-4128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-note","category-outing","category-react"],"_links":{"self":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/4128"}],"collection":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4128"}],"version-history":[{"count":14,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/4128\/revisions"}],"predecessor-version":[{"id":4163,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/4128\/revisions\/4163"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/media\/4130"}],"wp:attachment":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}