{"id":53146,"date":"2024-12-03T09:53:56","date_gmt":"2024-12-03T01:53:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53146\/"},"modified":"2024-12-03T09:53:56","modified_gmt":"2024-12-03T01:53:56","slug":"es6-%e4%b8%ad-const-%e5%92%8c-let-%e7%9a%84%e5%8c%ba%e5%88%ab%ef%bc%9a%e5%b8%b8%e9%87%8f%e5%92%8c%e5%8f%98%e9%87%8f%e5%a6%82%e4%bd%95%e5%ae%9a%e4%b9%89%e5%92%8c%e4%bd%bf%e7%94%a8%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53146\/","title":{"rendered":"ES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>ES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241127\/17326877976746b7b5970c7.jpg\" class=\"aligncenter\" title=\"ES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f\u63d2\u56fe\" alt=\"ES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>ES6 \u5e38\u91cf\u4e0e\u53d8\u91cf\u7684\u533a\u522b<\/strong><\/p>\n<p>ES6 \u4e2d\u5f15\u5165\u4e86 const \u548c let \u4e24\u79cd\u53d8\u91cf\u58f0\u660e\u65b9\u5f0f\uff0cconst \u7528\u4e8e\u58f0\u660e\u5e38\u91cf\uff0c\u800c let \u7528\u4e8e\u58f0\u660e\u53d8\u91cf\u3002<\/p>\n<p><strong>\u5e38\u91cf const<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 const \u58f0\u660e\u7684\u53d8\u91cf\u4e3a\u4e0d\u53ef\u53d8\u5e38\u91cf\uff0c\u5373\u8d4b\u503c\u540e\u65e0\u6cd5\u4fee\u6539\u3002<\/li>\n<li>\u5e38\u91cf\u5fc5\u987b\u5728\u58f0\u660e\u65f6\u521d\u59cb\u5316\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/li>\n<\/ul>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0cconst PI = &#8216;3.14&#8217; \u5c06 PI \u58f0\u660e\u4e3a\u5e38\u91cf\uff0c\u56e0\u6b64\u4e0d\u80fd\u518d\u4f7f\u7528 PI = &#8216;3.15555&#8217; \u91cd\u65b0\u8d4b\u503c\u3002<\/p>\n<p><strong>\u53d8\u91cf let<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 let \u58f0\u660e\u7684\u53d8\u91cf\u4e3a\u53ef\u53d8\u53d8\u91cf\uff0c\u53ef\u4ee5\u968f\u65f6\u91cd\u65b0\u8d4b\u503c\u3002<\/li>\n<li>\u53d8\u91cf\u5fc5\u987b\u5728\u58f0\u660e\u65f6\u521d\u59cb\u5316\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/li>\n<\/ul>\n<p><strong>let \u548c const \u7684\u533a\u522b<\/strong><\/p>\n<p>\u5c3d\u7ba1 let \u548c const \u90fd\u5fc5\u987b\u5728\u4f7f\u7528\u524d\u521d\u59cb\u5316\uff0c\u4f46\u5b83\u4eec\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e<strong>\u53ef\u53d8\u6027<\/strong>\u3002const \u58f0\u660e\u7684\u5e38\u91cf\u4e0d\u53ef\u4fee\u6539\uff0c\u800c let \u58f0\u660e\u7684\u53d8\u91cf\u53ef\u4ee5\u4fee\u6539\u3002<\/p>\n<p><strong>let PI = &#8216;2222&#8217;<\/strong><\/p>\n<p>\u5728\u6b64\u4ee3\u7801\u4e2d\uff0c\u867d\u7136\u4f7f\u7528\u4e86 const \u5b9a\u4e49\u4e86 PI \u5e38\u91cf\uff0c\u4f46\u968f\u540e\u53c8\u4f7f\u7528 let \u58f0\u660e\u4e86\u4e00\u4e2a\u65b0\u7684\u5c40\u90e8\u53d8\u91cf PI\u3002\u7531\u4e8e let \u58f0\u660e\u7684\u53d8\u91cf\u53ef\u4ee5\u91cd\u65b0\u8d4b\u503c\uff0c\u56e0\u6b64\u4e0d\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u5c06 let PI = &#8216;2222&#8217; \u6539\u4e3a const PI = &#8216;2222&#8217;\uff0c\u5219\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3a\u4e0d\u80fd\u91cd\u65b0\u8d4b\u503c const \u5e38\u91cf\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   SpringBoot \u96c6\u6210 Thymeleaf \u5e93\u63d0\u793a\u65e0\u6cd5\u89e3\u6790\u6a21\u677f\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>ES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f \u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aES6 \u4e2d const \u548c let \u7684\u533a\u522b\uff1a\u5e38\u91cf\u548c\u53d8\u91cf\u5982\u4f55\u5b9a\u4e49\u548c\u4f7f\u7528\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01 ES6 \u5e38\u91cf\u4e0e\u53d8\u91cf\u7684\u533a\u522b ES6 \u4e2d\u5f15\u5165\u4e86 const \u548c let \u4e24\u79cd\u53d8\u91cf\u58f0\u660e\u65b9\u5f0f\uff0cconst \u7528\u4e8e\u58f0\u660e\u5e38\u91cf\uff0c\u800c let \u7528\u4e8e\u58f0\u660e\u53d8\u91cf\u3002 \u5e38\u91cf const \u4f7f\u7528 const \u58f0\u660e\u7684\u53d8\u91cf\u4e3a\u4e0d\u53ef\u53d8\u5e38\u91cf\uff0c\u5373\u8d4b\u503c\u540e\u65e0\u6cd5\u4fee\u6539\u3002 \u5e38\u91cf\u5fc5\u987b\u5728\u58f0\u660e\u65f6\u521d\u59cb\u5316\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002 \u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0cconst PI = &#8216;3.14&#8217; \u5c06 PI \u58f0\u660e\u4e3a\u5e38\u91cf\uff0c\u56e0\u6b64\u4e0d\u80fd\u518d\u4f7f\u7528 PI = &#8216;3.15555&#8217; \u91cd\u65b0\u8d4b\u503c\u3002 \u53d8\u91cf let \u4f7f\u7528 let \u58f0\u660e\u7684\u53d8\u91cf\u4e3a\u53ef\u53d8\u53d8\u91cf\uff0c\u53ef\u4ee5\u968f\u65f6\u91cd\u65b0\u8d4b\u503c\u3002 \u53d8\u91cf\u5fc5\u987b\u5728\u58f0\u660e\u65f6\u521d\u59cb\u5316\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002 let \u548c const \u7684\u533a\u522b \u5c3d\u7ba1 let \u548c const \u90fd\u5fc5\u987b\u5728\u4f7f\u7528\u524d\u521d\u59cb\u5316\uff0c\u4f46\u5b83\u4eec\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u53ef\u53d8\u6027\u3002const [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53146","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53146"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53146\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}