{"id":103,"date":"2022-03-22T16:31:44","date_gmt":"2022-03-22T08:31:44","guid":{"rendered":"http:\/\/weboob.top\/blog\/?p=103"},"modified":"2022-03-22T16:31:44","modified_gmt":"2022-03-22T08:31:44","slug":"1-3-%e5%9f%ba%e6%9c%ac%e8%af%ad%e6%b3%95","status":"publish","type":"post","link":"http:\/\/blog.weboob.top\/?p=103","title":{"rendered":"1.3 \u57fa\u672c\u8bed\u6cd5"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/wangdoc.com\/javascript\/basic\/grammar.html\">\u539f\u6587\u4f20\u9001\u95e8<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/weboob.top\/blog\/?p=103\">\u6211\u7684\u535a\u5ba2<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1%E8%AF%AD%E5%8F%A5\">1.\u8bed\u53e5<\/h4>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u4e00\u822c\u4ee5\u884c\u4e3a\u5355\u4f4d\u3002<br \/>\u8bed\u53e5\uff08statement\uff09\u662f\u4e3a\u4e86\u5b8c\u6210\u67d0\u79cd\u4efb\u52a1\u800c\u8fdb\u884c\u7684\u64cd\u4f5c\u3002<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>var a = 1 + 3;\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>1 + 3 \u53eb\u505a\u8868\u8fbe\u5f0f\uff08express\uff09\u3002<br \/>\u8bed\u53e5\u4ee5 ; \u7ed3\u5c3e\u3002<\/p><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2%E5%8F%98%E9%87%8F\">2.\u53d8\u91cf<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>2.1\u6982\u5ff5js\u53d8\u91cf\u533a\u5206\u5927\u5c0f\u5199 a \u548c A \u662f\u4e24\u4e2a\u53d8\u91cf<code> var a; a \/\/ undefined <\/code>\u58f0\u660e\u540e\uff0c\u672a\u521d\u59cb\u5316\u7684\u53d8\u91cf\u503c\u4e3a&nbsp;<strong>undefined<\/strong><\/li><li>2.2 \u53d8\u91cf\u63d0\u5347Js\u5f15\u64ce\uff0c\u5148\u89e3\u6790\u4ee3\u7801\uff0c\u83b7\u53d6\u6240\u6709\u88ab\u58f0\u660e\u53d8\u91cf\u3002\u653e\u5728\u5934\u90e8\uff0c\u5728\u8fd0\u884c\u4ee3\u7801\uff0c\u5982\u679c\u540e\u8fb9\u58f0\u660e\u53d8\u91cf\uff0c\u5c31\u4f1a\u9020\u6210\u53d8\u91cf\u63d0\u5347\uff08hoisting\uff09<code> console.log(a); var a = 1; \/\/ undefined <\/code>\u4ee5\u4e0a\u4ee3\u7801\uff0c\u540c\u4e0b<code> var a; console.log(a); a = 1;<\/code><\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3%E6%A0%87%E8%AF%86%E7%AC%A6\">3.\u6807\u8bc6\u7b26<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; \u6807\u8bc6\u7b26\uff08identifier\uff09\uff1a\u6307\u7528\u6765\u8868\u793a\u5404\u79cd\u503c\u7684\u5408\u6cd5\u540d\u79f0\u3002\n&gt; \u6700\u5e38\u89c1\u7684\u5c31\u662f *\u53d8\u91cf\u540d* \u4ee5\u53ca *\u51fd\u6570\u540d*\u3002\n\n\u89c4\u5219\u5982\u4e0b\uff1a\n* \u7b2c\u4e00\u4e2a\u5b57\u7b26\uff0c\u53ef\u4ee5\u662f\u4efb\u610f Unicode \u5b57\u7b26\uff08\u5305\u62ec\u82f1\u6587\u6216\u5176\u4ed6\u8bed\u8a00\u7684\u5b57\u6bcd\uff0c\u4e2d\u6587\u4e5f\u662f\u5b8c\u5168\u53ef\u4ee5\u7684\uff09\uff0c\u4ee5\u53cadollar\uff08$\uff09\u548c\u4e0b\u5212\u7ebf\uff08_\uff09\u3002\uff08\u4e0d\u5305\u542b\u6570\u5b57\uff09\n* \u540e\u9762\u7684\u5b57\u7b26\uff0c\u9664\u4e86\u4ee5\u4e0a\u518d\u52a0\u4e0a\u6570\u5b57 0~9\u3002\n\n&gt; \u4ee5\u4e0b\u4fdd\u7559\u5b57\uff0c\u4e0d\u80fd\u7528\u4f5c\u6807\u8bc6\u7b26\n\n    arguments\u3001break\u3001case\u3001catch\u3001class\u3001const\u3001continue\u3001debugger\u3001default\u3001delete\u3001do\u3001else\u3001enum\u3001eval\u3001export\u3001extends\u3001false\u3001finally\u3001for\u3001function\u3001if\u3001implements\u3001import\u3001in\u3001instanceof\u3001interface\u3001let\u3001new\u3001null\u3001package\u3001private\u3001protected\u3001public\u3001return\u3001static\u3001super\u3001switch\u3001this\u3001throw\u3001true\u3001try\u3001typeof\u3001var\u3001void\u3001while\u3001with\u3001yield\u3002\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4%E6%B3%A8%E9%87%8A\">4.\u6ce8\u91ca<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; \u6ce8\u91ca\u5206\u4e24\u79cd\uff08\u517c\u5bb9html\u6ce8\u91ca\uff09\n\n    \/\/ \u8fd9\u91cc\u5199\u884c\u6ce8\u91ca\n\n    \/*\n    \u8fd9\u91cc\u5199\n    \u591a\u884c\n    \u6ce8\u91ca\n    *\/\n\n    &lt;!-- \u8fd9\u4e5f\u662f\u5355\u884c\u6ce8\u91ca --&gt;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5%E5%8C%BA%E5%9D%97\">5.\u533a\u5757<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt; \u5927\u62ec\u53f7\u53ef\u4ee5\u5c06\u4e00\u7ec4\u8bed\u53e5\u653e\u5728\u4e00\u8d77\u79f0\u4e3a block\n\n    {\n        var a = 1;\n    }\n    a \/\/ 1\n\n\u533a\u5757\u5bf9var\u547d\u4ee4\u4e0d\u6784\u6210\u5355\u72ec\u4f5c\u7528\u57df\u3002\nblock\u4e00\u822c\u4e0efor\u3001if\u3001while\u3001function\u8fde\u7528\u3002\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"6%E6%9D%A1%E4%BB%B6%E8%AF%AD%E5%8F%A5\">6.\u6761\u4ef6\u8bed\u53e5<\/h4>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>if \u6216 switch \u7ed3\u6784<\/p><\/blockquote>\n\n\n\n<ul class=\"wp-block-list\"><li>6.1 if \u7ed3\u6784<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(boolean)\n    statement expression;\n\n\/\/ \u6216\u8005\nif(boolean) statement expression;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u4e3a\u5355\u8bed\u53e5\uff0c\u591a\u6761\u8bed\u53e5\u9700\u8981\u653e\u5165block\u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(boolean){\n    statement expression;\n    statement expression;\n    statement expression;\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>6.2 if&#8230;else \u7ed3\u6784<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bed\u6cd5\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(3 === m){\n    statement exp1;\n}else{\n    statement exp2;\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fde\u7eed\u5224\u65ad\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(0 === m){\n    statement exp1;\n}else if(1 === m){\n    statement exp2;\n}else if(2 === m){\n    statement exp3;\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>6.3 swich\u7ed3\u6784<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u591a\u4e2aif\u8fde\u7528\u53ef\u4ee5\u7528\u8fd9\u4e2a\u7ed3\u6784\u4ee3\u66ff\uff0ccase \u4e3a\u5165\u53e3\uff0c\u76f4\u5230\u9047\u5230 break \u624d\u8df3\u51fa\u3002default\u4e3a\u9ed8\u8ba4\u5165\u53e3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>switch(n){\n    case \"value1\":\n    \/\/...\n    break;\n\n    case \"value2\":\n    \/\/...\n    break;\n\n    ...\n\n    case \"value&#91;N]\":\n    \/\/...\n    break;\n\n    default:\n    \/\/...\n}\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>switch \u4e0e case \u7684\u6bd4\u8f83\u4f7f\u7528&nbsp;<em><strong>\u4e25\u683c\u6a21\u5f0f<\/strong><\/em>\uff08===\uff09\uff0c\u4e0d\u4f1a\u8fdb\u884c\u81ea\u52a8\u7c7b\u578b\u8f6c\u6362<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>var x = 1;\nswitch (x){\n    case true:\n    console.log(\"x\u53d1\u751f\u4e86\u7c7b\u578b\u8f6c\u6362\");\n    break;\n\n    default:\n    console.log(\"x\u6ca1\u6709\u53d1\u751f\u7c7b\u578b\u8f6c\u6362\");\n}\n\/\/ x\u6ca1\u6709\u53d1\u751f\u7c7b\u578b\u8f6c\u6362\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>6.4 \u4e09\u5143\u8fd0\u7b97\u7b26 [?:]<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u76f8\u5f53\u4e8e if else<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>(condition) ? exp1 : exp2\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"7%E5%BE%AA%E7%8E%AF%E8%AF%AD%E5%8F%A5\">7.\u5faa\u73af\u8bed\u53e5<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>7.1 while \u5faa\u73af<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5355\u8bed\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while (condition)\n    statement exp;\n\/\/ \u6216\u8005\n\nwhile (condition) statement exp;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u591a\u6761\u6267\u884c\u8bed\u53e5\u9700\u8981\u653e\u5165 block \u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while (condition){\n    statement exp1;\n    ...\n    statement expN;\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>7.2 for \u5faa\u73af<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>initialize:\u521d\u59cb\u5316\u5faa\u73af\u53d8\u91cf<br \/>test:\u6d4b\u8bd5\u53d8\u91cf\u6761\u4ef6\uff0c\u53ea\u8981\u4e3a true \u5c31\u8fdb\u5165\u4e0b\u4e00\u5faa\u73af<br \/>increment:\u6bcf\u8f6e\u5faa\u73af\u7684\u6700\u540e\u4e00\u6b65\u64cd\u4f5c\uff0c\u4e00\u822c\u7528\u6765\u9012\u8fdb\u5faa\u73af\u53d8\u91cf<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>for ( initialize; test; increment){\n\n    statement exp1;\n    ...\n    statement expN;\n}\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u6240\u6709\u7684 for \u5faa\u73af\u90fd\u53ef\u6539\u5199\u4e3a while \u5faa\u73af<br \/>for \u5faa\u73af\u7684\u4e09\u90e8\u5206\u8868\u8fbe\u5f0f\uff0c\u53ef\u7701\u7565\u4efb\u4f55\u4e00\u4e2a<br \/>for ( ; ; ) \u4e3a\u6b7b\u5faa\u73af<\/p><\/blockquote>\n\n\n\n<ul class=\"wp-block-list\"><li>7.3 do&#8230;while\u5faa\u73af<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u6700\u5c11\u5faa\u73af\u4e00\u6b21<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>do{\n    statement exp1;\n    ...\n    statement expN;\n}while ( condition );\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u6700\u540e\u7684 ; \u4e0d\u80fd\u7701\u7565<\/p><\/blockquote>\n\n\n\n<ul class=\"wp-block-list\"><li>7.4 break \u548c continue<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>break \u8df3\u51fa\u5faa\u73af\u4f53 continue \u8df3\u5165\u4e0b\u4e00\u5faa\u73af<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u5b58\u5728\u5d4c\u5957\u60c5\u51b5\uff0c\u8fd9\u4e24\u4e2a\u8bed\u53e5\u90fd\u53ea\u9488\u5bf9\u6700\u5185\u5c42\u5faa\u73af<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>7.5 \u6807\u7b7e\uff08label\uff09<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u76f8\u5f53\u4e8e\u5b9a\u4f4d\u7b26\uff0c\u901a\u5e38\u4e0e continue \u6216 break \u8fde\u7528\uff0c\u53ef\u4ee5\u8df3\u51fa\u7279\u5b9a\u5faa\u73af\u3002<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>top:\n    for (var i = 0; i &lt; 3; i++){\n        for (var j = 0; j &lt; 3; j++){\n            if (1 === i &amp;&amp; 1 ===j) break top;\n            console.log(\"i=\" + i + \", j=\" + j);\n        }\n    }\n\n\/\/ i=0, j=0\n\/\/ i=0, j=1\n\/\/ i=0, j=2\n\/\/ i=1, j=0\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>label:{}<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>foo:{\n    console.log(1);\n    break foo;\n    console.log('\u672c\u884c\u4e0d\u4f1a\u8f93\u51fa');\n}\nconsole.log(2);\n\n\/\/ 1\n\/\/ 2\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u591a\u5c42\u5faa\u73af\uff0c\u53ef\u7528\u4e8e\u5b9a\u4f4d\u5230\u67d0\u5c42\u5faa\u73af<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>top:{\n    while (true){\n        sec:\n        for (var i = 0; i &lt; 3; i++){\n            for (var j = 0; j &lt; 3; j++){\n                if (1 === i &amp;&amp; 1 ===j) break sec;\n                console.log(\"i=\" + i + \", j=\" + j);\n            }\n        }\n    }\n}\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>continue \u7528\u6cd5<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>top:\n    for (var i = 0; i &lt; 3; i++){\n        for (var j = 0; j &lt; 3; j++){\n            if (i === 1 &amp;&amp; j === 1) continue top;\n            console.log('i=' + i + ', j=' + j);\n        }\n    }\n\n\/\/ i=0, j=0\n\/\/ i=0, j=1\n\/\/ i=0, j=2\n\/\/ i=1, j=0\n\/\/ i=2, j=0\n\/\/ i=2, j=1\n\/\/ i=2, j=2\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"8%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5\">8.\u53c2\u8003\u94fe\u63a5<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Axel Rauschmayer,&nbsp;<a href=\"https:\/\/2ality.com\/2013\/06\/basic-javascript.html\">Basic JavaScript for the impatient programmer<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u4f20\u9001\u95e8 \u6211\u7684\u535a\u5ba2 1.\u8bed\u53e5 \u4e00\u822c\u4ee5\u884c\u4e3a\u5355\u4f4d\u3002\u8bed\u53e5\uff08statement\uff09\u662f\u4e3a\u4e86\u5b8c\u6210\u67d0\u79cd\u4efb\u52a1\u800c\u8fdb\u884c\u7684\u64cd\u4f5c\u3002 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,10,5],"tags":[20],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-es5","category-js","category-code_article","tag-es5"],"_links":{"self":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103"}],"version-history":[{"count":0,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}