{"id":5957,"date":"2024-04-17T00:48:31","date_gmt":"2024-04-16T16:48:31","guid":{"rendered":"http:\/\/zyg.luchers.cn\/?p=5957"},"modified":"2024-04-17T00:48:31","modified_gmt":"2024-04-16T16:48:31","slug":"%e5%8d%81%e4%b8%89%e3%80%81es6%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"http:\/\/zyg.luchers.cn\/index.php\/2024\/04\/17\/%e5%8d%81%e4%b8%89%e3%80%81es6%e5%85%a5%e9%97%a8\/","title":{"rendered":"\u5341\u4e09\u3001ES6\u5165\u95e8"},"content":{"rendered":"<h1>\u5341\u4e03\u3001ES6\u5165\u95e8<\/h1>\n<h2>1\u3001ECMAScript 6 \u7b80\u4ecb<\/h2>\n<p>ECMAScript 6.0\uff08\u4ee5\u4e0b\u7b80\u79f0 ES6\uff09\u662f JavaScript \u8bed\u8a00\u7684\u4e0b\u4e00\u4ee3\u6807\u51c6\uff0c\u5df2\u7ecf\u5728 2015 \u5e74 6 \u6708\u6b63\u5f0f\u53d1\u5e03\u4e86\u3002\u5b83\u7684\u76ee\u6807\uff0c\u662f\u4f7f\u5f97 JavaScript \u8bed\u8a00\u53ef\u4ee5\u7528\u6765\u7f16\u5199\u590d\u6742\u7684\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\uff0c\u6210\u4e3a\u4f01\u4e1a\u7ea7\u5f00\u53d1\u8bed\u8a00\u3002<\/p>\n<h2>2\u3001\u57fa\u672c\u8bed\u6cd5<\/h2>\n<p>\u672c\u90e8\u5206\u53ea\u5b66\u4e60\u524d\u7aef\u5f00\u53d1\u4e2dES6\u7684\u6700\u5c11\u5fc5\u8981\u77e5\u8bc6\uff0c\u65b9\u4fbf\u540e\u9762\u9879\u76ee\u5f00\u53d1\u4e2d\u5bf9\u4ee3\u7801\u7684\u7406\u89e3\u3002<\/p>\n<h3>2.1\u3001\u6a21\u677f\u5b57\u7b26\u4e32<\/h3>\n<p>\u521b\u5efa \u6a21\u677f\u5b57\u7b26\u4e32.html<\/p>\n<pre><code class=\"language-javascript\">\/\/ 2\u3001\u5b57\u7b26\u4e32\u63d2\u5165\u53d8\u91cf\u548c\u8868\u8fbe\u5f0f\u3002\u53d8\u91cf\u540d\u5199\u5728 ${} \u4e2d\uff0c${} \u4e2d\u53ef\u4ee5\u653e\u5165 JavaScript \u8868\u8fbe\u5f0f\u3002\nlet name = &quot;Mike&quot;\nlet age = 27\nlet info = `My Name is ${name},I am ${age+1} years old next year.`\nconsole.log(info)\n\/\/ My Name is Mike,I am 28 years old next year.<\/code><\/pre>\n<h3>2.2\u3001\u5bf9\u8c61\u62d3\u5c55\u8fd0\u7b97\u7b26<\/h3>\n<p>\u521b\u5efa \u5bf9\u8c61\u62d3\u5c55\u8fd0\u7b97\u7b26.html<\/p>\n<p>\u62d3\u5c55\u8fd0\u7b97\u7b26\uff08...\uff09\u7528\u4e8e\u53d6\u51fa\u53c2\u6570\u5bf9\u8c61\u6240\u6709\u53ef\u904d\u5386\u5c5e\u6027\u7136\u540e\u62f7\u8d1d\u5230\u5f53\u524d\u5bf9\u8c61\u3002<\/p>\n<pre><code class=\"language-javascript\">\/\/ 1\u3001\u62f7\u8d1d\u5bf9\u8c61\nlet person1 = {name: &quot;Amy&quot;, age: 15}\nlet someone = { ...person1 }\nconsole.log(someone)  \/\/{name: &quot;Amy&quot;, age: 15}<\/code><\/pre>\n<h2><strong>2.3\u3001\u7bad\u5934\u51fd\u6570<\/strong><\/h2>\n<p>\u521b\u5efa \u7bad\u5934\u51fd\u6570.html<\/p>\n<p>\u7bad\u5934\u51fd\u6570\u63d0\u4f9b\u4e86\u4e00\u79cd\u66f4\u52a0\u7b80\u6d01\u7684\u51fd\u6570\u4e66\u5199\u65b9\u5f0f\u3002\u57fa\u672c\u8bed\u6cd5\u662f\uff1a<code>\u53c2\u6570 =&gt; \u51fd\u6570\u4f53<\/code><\/p>\n<pre><code class=\"language-javascript\">\/\/ \u4f20\u7edf\nvar f1 = function(a){\n    return a\n}\nconsole.log(f1(1))\n\/\/ ES6\nvar f2 = a =&gt; a\nconsole.log(f2(1))<\/code><\/pre>\n<pre><code class=\"language-javascript\">\/\/ \u5f53\u7bad\u5934\u51fd\u6570\u6ca1\u6709\u53c2\u6570\u6216\u8005\u6709\u591a\u4e2a\u53c2\u6570\uff0c\u8981\u7528 () \u62ec\u8d77\u6765\u3002\n\/\/ \u5f53\u7bad\u5934\u51fd\u6570\u51fd\u6570\u4f53\u6709\u591a\u884c\u8bed\u53e5\uff0c\u7528 {} \u5305\u88f9\u8d77\u6765\uff0c\u8868\u793a\u4ee3\u7801\u5757\uff0c\n\/\/ \u5f53\u53ea\u6709\u4e00\u884c\u8bed\u53e5\uff0c\u5e76\u4e14\u9700\u8981\u8fd4\u56de\u7ed3\u679c\u65f6\uff0c\u53ef\u4ee5\u7701\u7565 {} , \u7ed3\u679c\u4f1a\u81ea\u52a8\u8fd4\u56de\u3002\nvar f3 = (a,b) =&gt; {\n    let result = a+b\n    return result\n}\nconsole.log(f3(6,2))  \/\/ 8\n\/\/ \u524d\u9762\u4ee3\u7801\u76f8\u5f53\u4e8e\uff1a\nvar f4 = (a,b) =&gt; a+b<\/code><\/pre>\n<p>\u7bad\u5934\u51fd\u6570\u591a\u7528\u4e8e\u533f\u540d\u51fd\u6570\u7684\u5b9a\u4e49<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5341\u4e03\u3001ES6\u5165\u95e8 1\u3001ECMAScript 6 \u7b80\u4ecb ECMAScript 6.0\uff08\u4ee5\u4e0b\u7b80\u79f0 ES6\uff09\u662f Ja [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-5957","post","type-post","status-publish","format-standard","hentry","category-javaweb"],"_links":{"self":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5957"}],"version-history":[{"count":1,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5957\/revisions"}],"predecessor-version":[{"id":5958,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5957\/revisions\/5958"}],"wp:attachment":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5957"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}