{"id":367,"date":"2017-05-19T15:12:59","date_gmt":"2017-05-19T06:12:59","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2017\/05\/19\/ecmascript01"},"modified":"2022-10-26T06:57:30","modified_gmt":"2022-10-25T21:57:30","slug":"ecmascript01","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2017\/05\/19\/ecmascript01\/","title":{"rendered":"\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5b66\u7fd2 ECMAScript \u7b2c1\u56de"},"content":{"rendered":"

MMM\u306b\u5165\u793e\u3057\u3066\u3082\u3046\u3059\u3050\u534a\u5e74\u306b\u306a\u308a\u307e\u3057\u305f\u3002
\n\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u5b66\u7fd2\u306f\u696d\u52d9\u306b\u306a\u305e\u3063\u3066\u306f\u884c\u3048\u3066\u3044\u307e\u3059\u304c\u3001\u4f53\u7cfb\u7684\u306b\u5b66\u3079\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5b66\u7fd2\u3092\u4eca\u6708\u304b\u3089\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u3053\u3068\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n

\u3069\u3093\u306a\u5185\u5bb9\u3092\u5b66\u7fd2\u3057\u3066\u3044\u304f\u304b\u3092\u30d6\u30ed\u30b0\u3067\u307e\u3068\u3081\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

\u7b2c1\u56de\u3068\u306a\u308b\u4eca\u56de\u306fECMAScript<\/strong>\u306b\u3064\u3044\u3066\u5b66\u3093\u3067\u3044\u304d\u307e\u3057\u305f\u3002<\/p>\n

\u5b9f\u306f\u3044\u3046\u3068\u5b9f\u52d9\u3067ECMAScript6\u3092\u6271\u3063\u305f\u306e\u306f\u521d\u3081\u3066\u3067\u3057\u305f\u3002
\n\u306a\u3093\u3068\u306a\u304f\u4f7f\u3063\u3066\u5c45\u305f\u90e8\u5206\u3082\u591a\u304b\u3063\u305f\u306e\u3067\u3001\u4eca\u56de\u306f\u307e\u305a\u57fa\u672c\u69cb\u6587\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n


\n

\u57fa\u672c\u69cb\u6587<\/h2>\n

let\u547d\u4ee4<\/h3>\n

\u5f93\u6765\u306eJavaScript\u3067\u306f\u3001\u30d6\u30ed\u30c3\u30af\u30ec\u30d9\u30eb\u306e\u30b9\u30b3\u30fc\u30d7\u306f\u5b58\u5728\u3057\u306a\u304b\u3063\u305f\u304c\u3001let\u547d\u4ee4\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u304c\u6709\u52b9\u306a\u5909\u6570\u3092\u5ba3\u8a00\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n

if (true) {\n  var i = 1;\n}\n\nconsole.log(i);\n\/\/ \u5f93\u6765\uff1a1\n\/\/ ECMAScript\uff1a\u30a8\u30e9\u30fc(i is not defined)<\/code><\/pre>\n

\u307e\u305f\u3001var\u547d\u4ee4\u306f\u91cd\u8907\u3092\u8a8d\u3081\u3089\u308c\u3066\u3044\u308b\u304c\u3001let\u3067\u306f\u91cd\u8907\u3092\u8a8d\u3081\u307e\u305b\u3093\u3002
\nvar\u547d\u4ee4\u306fECMAScript\u3067\u3082\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u304c\u3001\u30b9\u30b3\u30fc\u30d7\u306f\u6700\u5927\u9650\u9650\u5b9a\u3059\u3079\u304d<\/strong>\u3001\u91cd\u8907\u30c1\u30a7\u30c3\u30af\u3092\u30b3\u30f3\u30d1\u30a4\u30e9\u30fc\u306b\u4efb\u305b\u3089\u308c\u308b<\/strong> \u3068\u3044\u3046\u7406\u7531\u304b\u3089\u3001\u4eca\u5f8c\u306flet\u3092\u512a\u5148\u3057\u3066\u5229\u7528\u3057\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n

const\u547d\u4ee4<\/h3>\n

\u79c1\u3082\u6700\u521d\u8aa4\u3063\u305f\u8a8d\u8b58\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001const\u547d\u4ee4\u306f \u300c\u5909\u66f4\u3067\u304d\u306a\u3044\u300d\u3067\u306f\u306a\u304f\u300c\u518d\u5165\u3067\u304d\u306a\u3044\u300d<\/strong> \u3068\u3044\u3046\u8a8d\u8b58\u304c\u6b63\u3057\u3044\u305d\u3046\u3067\u3059\u3002<\/p>\n

\u30a8\u30e9\u30fc\u306b\u306a\u308b\u4f8b<\/strong><\/p>\n

const data = 100;\ndata = 150; \/\/ \u30a8\u30e9\u30fc<\/code><\/pre>\n

\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\u4f8b<\/strong><\/p>\n

const data = [1, 2, 3];\ndata[0] = 10;\nconsole.log(data);\n\/\/ \u7d50\u679c\uff1a[10, 2, 3]<\/code><\/pre>\n

\u203bconst\u3082let\u3068\u540c\u69d8\u306b\u30d6\u30ed\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3067\u3059\u3002<\/p>\n

\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u6587\u5b57\u5217<\/h3>\n

\u500b\u4eba\u7684\u306b\u3053\u308c\u4fbf\u5229\u3063\u3066\u611f\u52d5\u3057\u3066\u307e\u3057\u305f\u3002
\n\u4f8b\u3048\u3070\u30fb\u30fb\u30fb<\/p>\n

\u3053\u3093\u306b\u3061\u306f
\n\u25cb\u25cb\u3055\u3093<\/p>\n

\u3068\u3044\u3046\u6587\u5b57\u5217\u3092\u51fa\u529b\u3059\u308b\u5834\u5408\u3002<\/p>\n

let str = `\u3053\u3093\u306b\u3061\u306f\n\u25cb\u25cb\u3055\u3093`;<\/code><\/pre>\n

\u3068\u3044\u3046\u611f\u3058\u3067\u66f8\u3051\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u307e\u305f\u3001\u25cb\u25cb\u3092\u5909\u6570\u306e\u5024\u306b\u3057\u305f\u3044\u5834\u5408\u306f<\/p>\n

let name = '\u5c71\u7530';\nlet str = `\u3053\u3093\u306b\u3061\u306f\n${name}\u3055\u3093`;<\/code><\/pre>\n

\u3068\u3044\u3046\u5f62\u3067\u66f8\u3051\u307e\u3059\u3002\u4fbf\u5229\u3067\u3059\u3002<\/p>\n

Symbol<\/h3>\n

ECMAScript\u3067\u306f\u65b0\u3057\u304f\u30c7\u30fc\u30bf\u578b Symbol<\/strong> \u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002
\n\u540d\u524d\u306e\u901a\u308a\u30b7\u30f3\u30dc\u30eb\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306e\u578b\u3067\u3059\u3002<\/p>\n

\u4e00\u5ea6\u4f5c\u6210\u3057\u305f\u30b7\u30f3\u30dc\u30eb\u306f\u3001\u305d\u308c\u81ea\u8eab\u3068\u306e\u307f\u7b49\u3057\u304f\u306a\u308a\u307e\u3059<\/strong><\/p>\n

\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6587\u5b57\u5217\u3067\u6bd4\u8f03\u3057\u3066\u3082\u7d50\u679c\u306ffalse\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

const JAPAN = Symbol('japan');\n\nconsole.log(JAPAN === 'japan');\n\/\/ \u7d50\u679c\uff1afalse<\/code><\/pre>\n

\u81ea\u8eab\u3068\u306e\u307f\u7b49\u3057\u304f\u306a\u308b\u306e\u3067\u3001\u4f8b\u3048\u540d\u524d\u304c\u540c\u3058\u3067\u3082\u7d50\u679c\u306ffalse\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

const JAPAN1 = Symbol('japan');\nconst JAPAN2 = Symbol('japan');\n\nconsole.log(JAPAN1 === JAPAN2);\n\/\/ \u7d50\u679c\uff1afalse<\/code><\/pre>\n

\u307e\u305f\u3001\u6697\u9ed9\u7684\u306a\u578b\u5909\u63db\u306f\u3067\u304d\u307e\u305b\u3093\u304c boolean<\/strong> \u3068 object<\/strong> \u3078\u306e\u5909\u63db\u306f\u53ef\u80fd\u3067\u3059\u3002<\/p>\n

\u306a\u304b\u306a\u304b\u9650\u5b9a\u7684\u306a\u611f\u3058\u3082\u3057\u307e\u3059\u304c\u3001 \u975e\u516c\u958b\u306a\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5b9a\u7fa9<\/strong> \u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u3002
\n\u3053\u306e\u8fba\u308a\u306f\u7a4d\u6975\u7684\u306b\u53d6\u308a\u5165\u308c\u3066\u3044\u304d\u305f\u3044\u3067\u3059(\u309c\u309c)<\/p>\n

\u5206\u5272\u4ee3\u5165<\/h3>\n

\u914d\u5217\u3084\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5206\u89e3\u3057\u3001\u305d\u306e\u8981\u7d20\u3084\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u500b\u3005\u306e\u5909\u6570\u306b\u5c55\u958b\u3059\u308b\u305f\u3081\u306e\u69cb\u6587\u3067\u3059\u3002<\/p>\n

\u4f8b\u3048\u3070\u30fb\u30fb\u30fb<\/p>\n

let [hoge, foo] = [15, 20];\n\nconsole.log(hoge);\n\/\/ \u7d50\u679c\uff1a15\n\nconsole.log(foo);\n\/\/ \u7d50\u679c\uff1a20<\/code><\/pre>\n

\u6f14\u7b97\u5b50\u3092\u4f7f\u3046\u3053\u3068\u3067\u307e\u3068\u3081\u3066\u914d\u5217\u3068\u3057\u3066\u53d6\u308a\u51fa\u3059\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n

let [hoge, foo, ...other] = [10, 20, 30, 40, 50, 60];\n\nconsole.log(hoge);\n\/\/ \u7d50\u679c\uff1a10\n\nconsole.log(foo);\n\/\/ \u7d50\u679c\uff1a20\n\nconsole.log(other);\n\/\/ \u7d50\u679c\uff1a[30, 40, 50, 60]<\/code><\/pre>\n

\u914d\u5217\u3092\u8fd4\u3059\u95a2\u6570\u304b\u3089\u3001\u500b\u3005\u306e\u5909\u6570\u306b\u5024\u3092\u5272\u308a\u5f53\u3066\u305f\u3044\u5834\u5408\u306a\u3069\u306f\u4fbf\u5229\u305d\u3046\u3067\u3059\u306d\uff01<\/p>\n

const destructure = (() => {\n  let result1 = 10;\n  let result2 = 20;\n  return [result1, result2];\n});\n\nlet [hoge, foo] = destructure();\n\nconsole.log(hoge);\n\/\/ \u7d50\u679c\uff1a10\n\nconsole.log(foo);\n\/\/ \u7d50\u679c\uff1a20<\/code><\/pre>\n

\u4e0a\u8a18\u306eresult2\u3060\u3051\u3092\u5272\u308a\u5f53\u3066\u305f\u3044\u5834\u5408\u306f\u3001\u5207\u308a\u6368\u3066\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n

let [, foo] = destructure();<\/code><\/pre>\n

\u5909\u6570\u3092\u5165\u308c\u66ff\u3048\u305f\u3044\u5834\u5408\u306a\u3069\u3082\u3001\u4fbf\u5229\u305d\u3046\u3067\u3059\u3002<\/p>\n


\n

\u3044\u304b\u304c\u3067\u3057\u305f\u3067\u3057\u3087\u3046\u304b\u3002
\n\u5f93\u6765\u306eJavaScript\u306b\u6bd4\u3079\u308b\u3068\u3001\u5927\u5206\u4ed5\u69d8\u304c\u5b89\u5b9a\u3057\u3066\u304d\u305f\u3088\u3046\u306b\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n

\u65b0\u9bae\u306a\u6c17\u6301\u3061\u3067\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3067\u304d\u305d\u3046\u3067\u3059\u306d\uff01\u30ac\u30f3\u30ac\u30f3\u4f7f\u3063\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

MMM\u306b\u5165\u793e\u3057\u3066\u3082\u3046\u3059\u3050\u534a\u5e74\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u306e\u5b66\u7fd2\u306f\u696d\u52d9\u306b\u306a\u305e\u3063\u3066\u306f\u884c\u3048\u3066\u3044\u307e\u3059\u304c\u3001\u4f53\u7cfb\u7684\u306b\u5b66\u3079\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5b66\u7fd2\u3092\u4eca\u6708\u304b\u3089\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u3053\u3068\u3068\u306a\u308a\u307e\u3057\u305f\u3002 \u3069\u3093\u306a\u5185\u5bb9\u3092\u5b66\u7fd2\u3057\u3066\u3044\u304f\u304b\u3092\u30d6\u30ed\u30b0\u3067\u307e\u3068\u3081\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u7b2c1\u56de\u3068\u306a\u308b\u4eca\u56de\u306fECMAScript\u306b\u3064\u3044\u3066\u5b66\u3093\u3067\u3044\u304d\u307e\u3057\u305f\u3002 \u5b9f\u306f\u3044\u3046\u3068\u5b9f\u52d9\u3067ECMAScript6\u3092\u6271\u3063\u305f\u306e\u306f\u521d\u3081\u3066\u3067\u3057\u305f\u3002 \u306a\u3093\u3068\u306a […]<\/p>\n","protected":false},"author":1,"featured_media":684,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[438],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/367"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=367"}],"version-history":[{"count":1,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/367\/revisions"}],"predecessor-version":[{"id":3282,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/367\/revisions\/3282"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}