const \u547d\u4ee4<\/strong><\/div>\nconst \u58f0\u660e\u4e00\u4e2a\u53ea\u8bfb\u53d8\u91cf\uff0c\u58f0\u660e\u4e4b\u540e\u4e0d\u5141\u8bb8\u6539\u53d8\u3002\u610f\u5473\u7740\uff0c\u4e00\u65e6\u58f0\u660e\u5fc5\u987b\u521d\u59cb\u5316\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n
\u57fa\u672c\u7528\u6cd5:<\/p>\n
const PI = \"3.1415926\";\r\nPI \/\/ 3.1415926\r\n\r\nconst MY_AGE; \/\/ SyntaxError: Missing initializer in const declaration<\/pre>\n\u6682\u65f6\u6027\u6b7b\u533a:<\/p>\n
var PI = \"a\";\r\nif(true){\r\n console.log(PI); \/\/ ReferenceError: PI is not defined\r\n const PI = \"3.1415926\";\r\n}<\/pre>\nES6 \u660e\u786e\u89c4\u5b9a\uff0c\u4ee3\u7801\u5757\u5185\u5982\u679c\u5b58\u5728 let \u6216\u8005 const\uff0c\u4ee3\u7801\u5757\u4f1a\u5bf9\u8fd9\u4e9b\u547d\u4ee4\u58f0\u660e\u7684\u53d8\u91cf\u4ece\u5757\u7684\u5f00\u59cb\u5c31\u5f62\u6210\u4e00\u4e2a\u5c01\u95ed\u4f5c\u7528\u57df\u3002\u4ee3\u7801\u5757\u5185\uff0c\u5728\u58f0\u660e\u53d8\u91cf PI \u4e4b\u524d\u4f7f\u7528\u5b83\u4f1a\u62a5\u9519\u3002<\/p>\n
\u6ce8\u610f\u8981\u70b9<\/strong><\/div>\nconst \u5982\u4f55\u505a\u5230\u53d8\u91cf\u5728\u58f0\u660e\u521d\u59cb\u5316\u4e4b\u540e\u4e0d\u5141\u8bb8\u6539\u53d8\u7684\uff1f\u5176\u5b9e const \u5176\u5b9e\u4fdd\u8bc1\u7684\u4e0d\u662f\u53d8\u91cf\u7684\u503c\u4e0d\u53d8\uff0c\u800c\u662f\u4fdd\u8bc1\u53d8\u91cf\u6307\u5411\u7684\u5185\u5b58\u5730\u5740\u6240\u4fdd\u5b58\u7684\u6570\u636e\u4e0d\u5141\u8bb8\u6539\u52a8\u3002\u6b64\u65f6\uff0c\u4f60\u53ef\u80fd\u5df2\u7ecf\u60f3\u5230\uff0c\u7b80\u5355\u7c7b\u578b\u548c\u590d\u5408\u7c7b\u578b\u4fdd\u5b58\u503c\u7684\u65b9\u5f0f\u662f\u4e0d\u540c\u7684\u3002\u662f\u7684\uff0c\u5bf9\u4e8e\u7b80\u5355\u7c7b\u578b\uff08\u6570\u503c number\u3001\u5b57\u7b26\u4e32 string \u3001\u5e03\u5c14\u503c boolean\uff09,\u503c\u5c31\u4fdd\u5b58\u5728\u53d8\u91cf\u6307\u5411\u7684\u90a3\u4e2a\u5185\u5b58\u5730\u5740\uff0c\u56e0\u6b64 const \u58f0\u660e\u7684\u7b80\u5355\u7c7b\u578b\u53d8\u91cf\u7b49\u540c\u4e8e\u5e38\u91cf\u3002\u800c\u590d\u6742\u7c7b\u578b\uff08\u5bf9\u8c61 object\uff0c\u6570\u7ec4 array\uff0c\u51fd\u6570 function\uff09\uff0c\u53d8\u91cf\u6307\u5411\u7684\u5185\u5b58\u5730\u5740\u5176\u5b9e\u662f\u4fdd\u5b58\u4e86\u4e00\u4e2a\u6307\u5411\u5b9e\u9645\u6570\u636e\u7684\u6307\u9488\uff0c\u6240\u4ee5 const \u53ea\u80fd\u4fdd\u8bc1\u6307\u9488\u662f\u56fa\u5b9a\u7684\uff0c\u81f3\u4e8e\u6307\u9488\u6307\u5411\u7684\u6570\u636e\u7ed3\u6784\u53d8\u4e0d\u53d8\u5c31\u65e0\u6cd5\u63a7\u5236\u4e86\uff0c\u6240\u4ee5\u4f7f\u7528 const \u58f0\u660e\u590d\u6742\u7c7b\u578b\u5bf9\u8c61\u65f6\u8981\u614e\u91cd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u57fa\u672c\u7528\u6cd5: { let a = 0; a \/\/ 0 } a \/\/ \u62a5\u9519 ReferenceError: a i […]<\/p>\n","protected":false},"author":321,"featured_media":199434,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-199432","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\/199432","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=199432"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/199432\/revisions"}],"predecessor-version":[{"id":199440,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/199432\/revisions\/199440"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/199434"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=199432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=199432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=199432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}