{"id":197053,"date":"2020-08-06T08:45:05","date_gmt":"2020-08-06T00:45:05","guid":{"rendered":"https:\/\/gulass.cn\/?p=197053"},"modified":"2020-07-26T14:46:32","modified_gmt":"2020-07-26T06:46:32","slug":"overview-of-es6","status":"publish","type":"post","link":"https:\/\/gulass.cn\/overview-of-es6.html","title":{"rendered":"ES6\u89e3\u6784\u8d4b\u503c\u6982\u8ff0"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u89e3\u6784\u8d4b\u503c\u662f\u5bf9\u8d4b\u503c\u8fd0\u7b97\u7b26\u7684\u6269\u5c55\u3002\u662f\u4e00\u79cd\u9488\u5bf9\u6570\u7ec4\u6216\u8005\u5bf9\u8c61\u8fdb\u884c\u6a21\u5f0f\u5339\u914d\uff0c\u7136\u540e\u5bf9\u5176\u4e2d\u7684\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002\u5728\u4ee3\u7801\u4e66\u5199\u4e0a\u7b80\u6d01\u4e14\u6613\u8bfb\uff0c\u8bed\u4e49\u66f4\u52a0\u6e05\u6670\u660e\u4e86\uff1b\u4e5f\u65b9\u4fbf\u4e86\u590d\u6742\u5bf9\u8c61\u4e2d\u6570\u636e\u5b57\u6bb5\u83b7\u53d6\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u89e3\u6784\u6a21\u578b<\/strong><\/div>\n

\u5728\u89e3\u6784\u4e2d\uff0c\u6709\u4e0b\u9762\u4e24\u90e8\u5206\u53c2\u4e0e\uff1a<\/p>\n

    \n
  1. \u89e3\u6784\u7684\u6e90\uff0c\u89e3\u6784\u8d4b\u503c\u8868\u8fbe\u5f0f\u7684\u53f3\u8fb9\u90e8\u5206\u3002<\/li>\n
  2. \u89e3\u6784\u7684\u76ee\u6807\uff0c\u89e3\u6784\u8d4b\u503c\u8868\u8fbe\u5f0f\u7684\u5de6\u8fb9\u90e8\u5206\u3002<\/li>\n<\/ol>\n
    \u6570\u7ec4\u6a21\u578b\u7684\u89e3\u6784\uff08Array\uff09<\/strong><\/div>\n
    \u57fa\u672c<\/strong><\/span><\/div>\n
    let [a, b, c] = [1, 2, 3];\r\n\/\/ a = 1\r\n\/\/ b = 2\r\n\/\/ c = 3<\/pre>\n
    \u53ef\u5d4c\u5957<\/strong><\/span><\/div>\n
    let [a, [[b], c]] = [1, [[2], 3]];\r\n\/\/ a = 1\r\n\/\/ b = 2\r\n\/\/ c = 3<\/pre>\n
    \u53ef\u5ffd\u7565<\/strong><\/span><\/div>\n
    let [a, , b] = [1, 2, 3];\r\n\/\/ a = 1\r\n\/\/ b = 3<\/pre>\n
    \u4e0d\u5b8c\u5168\u89e3\u6784<\/strong><\/span><\/div>\n
    let [a = 1, b] = []; \/\/ a = 1, b = undefined<\/pre>\n
    \u5269\u4f59\u8fd0\u7b97\u7b26<\/strong><\/span><\/div>\n
    let [a, ...b] = [1, 2, 3];\r\n\/\/a = 1\r\n\/\/b = [2, 3]<\/pre>\n
    \u5b57\u7b26\u4e32\u7b49<\/strong><\/span><\/div>\n

    \u5728\u6570\u7ec4\u7684\u89e3\u6784\u4e2d\uff0c\u89e3\u6784\u7684\u76ee\u6807\u82e5\u4e3a\u53ef\u904d\u5386\u5bf9\u8c61\uff0c\u7686\u53ef\u8fdb\u884c\u89e3\u6784\u8d4b\u503c\u3002\u53ef\u904d\u5386\u5bf9\u8c61\u5373\u5b9e\u73b0 Iterator \u63a5\u53e3\u7684\u6570\u636e\u3002<\/p>\n

    let [a, b, c, d, e] = 'hello';\r\n\/\/ a = 'h'\r\n\/\/ b = 'e'\r\n\/\/ c = 'l'\r\n\/\/ d = 'l'\r\n\/\/ e = 'o'<\/pre>\n
    \u89e3\u6784\u9ed8\u8ba4\u503c<\/strong><\/span><\/div>\n
    let [a = 2] = [undefined]; \/\/ a = 2<\/pre>\n

    \u5f53\u89e3\u6784\u6a21\u5f0f\u6709\u5339\u914d\u7ed3\u679c\uff0c\u4e14\u5339\u914d\u7ed3\u679c\u662f undefined \u65f6\uff0c\u4f1a\u89e6\u53d1\u9ed8\u8ba4\u503c\u4f5c\u4e3a\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n

    let [a = 3, b = a] = [];     \/\/ a = 3, b = 3\r\nlet [a = 3, b = a] = [1];    \/\/ a = 1, b = 1\r\nlet [a = 3, b = a] = [1, 2]; \/\/ a = 1, b = 2<\/pre>\n
      \na \u4e0e b \u5339\u914d\u7ed3\u679c\u4e3a undefined \uff0c\u89e6\u53d1\u9ed8\u8ba4\u503c\uff1aa = 3; b = a =3
      \na \u6b63\u5e38\u89e3\u6784\u8d4b\u503c\uff0c\u5339\u914d\u7ed3\u679c\uff1aa = 1\uff0cb \u5339\u914d\u7ed3\u679c undefined \uff0c\u89e6\u53d1\u9ed8\u8ba4\u503c\uff1ab = a =1
      \na \u4e0e b \u6b63\u5e38\u89e3\u6784\u8d4b\u503c\uff0c\u5339\u914d\u7ed3\u679c\uff1aa = 1\uff0cb = 2<\/ol>\n
      \u5bf9\u8c61\u6a21\u578b\u7684\u89e3\u6784\uff08Object\uff09<\/strong><\/div>\n
      \u57fa\u672c<\/strong><\/span><\/div>\n
      let { foo, bar } = { foo: 'aaa', bar: 'bbb' };\r\n\/\/ foo = 'aaa'\r\n\/\/ bar = 'bbb'\r\n \r\nlet { baz : foo } = { baz : 'ddd' };\r\n\/\/ foo = 'ddd'<\/pre>\n
      \u53ef\u5d4c\u5957\u53ef\u5ffd\u7565<\/strong><\/span><\/div>\n
      let obj = {p: ['hello', {y: 'world'}] };\r\nlet {p: [x, { y }] } = obj;\r\n\/\/ x = 'hello'\r\n\/\/ y = 'world'\r\nlet obj = {p: ['hello', {y: 'world'}] };\r\nlet {p: [x, {  }] } = obj;\r\n\/\/ x = 'hello'<\/pre>\n
      \u4e0d\u5b8c\u5168\u89e3\u6784<\/strong><\/span><\/div>\n
      let obj = {p: [{y: 'world'}] };\r\nlet {p: [{ y }, x ] } = obj;\r\n\/\/ x = undefined\r\n\/\/ y = 'world'<\/pre>\n
      \u5269\u4f59\u8fd0\u7b97\u7b26<\/strong><\/span><\/div>\n
      let {a, b, ...rest} = {a: 10, b: 20, c: 30, d: 40};\r\n\/\/ a = 10\r\n\/\/ b = 20\r\n\/\/ rest = {c: 30, d: 40}<\/pre>\n
      \u89e3\u6784\u9ed8\u8ba4\u503c<\/strong><\/span><\/div>\n
      let {a = 10, b = 5} = {a: 3};\r\n\/\/ a = 3; b = 5;\r\nlet {a: aa = 10, b: bb = 5} = {a: 3};\r\n\/\/ aa = 3; bb = 5;<\/pre>\n","protected":false},"excerpt":{"rendered":"

      \u5728\u89e3\u6784\u4e2d\uff0c\u6709\u4e0b\u9762\u4e24\u90e8\u5206\u53c2\u4e0e\uff1a \u89e3\u6784\u7684\u6e90\uff0c\u89e3\u6784\u8d4b\u503c\u8868\u8fbe\u5f0f\u7684\u53f3\u8fb9\u90e8\u5206\u3002 \u89e3\u6784\u7684\u76ee\u6807\uff0c\u89e3\u6784\u8d4b\u503c\u8868\u8fbe\u5f0f\u7684\u5de6\u8fb9\u90e8\u5206\u3002 l […]<\/p>\n","protected":false},"author":321,"featured_media":197056,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-197053","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/197053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/321"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=197053"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/197053\/revisions"}],"predecessor-version":[{"id":197061,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/197053\/revisions\/197061"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/197056"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=197053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=197053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=197053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}