{"id":17,"date":"2007-05-21T00:02:24","date_gmt":"2007-05-21T04:02:24","guid":{"rendered":"http:\/\/prglab.com\/blog\/?page_id=17"},"modified":"2007-08-25T13:48:43","modified_gmt":"2007-08-25T17:48:43","slug":"js-loopbreak","status":"publish","type":"page","link":"https:\/\/www.prglab.com\/blog\/js-tutorial\/js-loopbreak","title":{"rendered":"JavaScript \u5faa\u73af\u7684Break \u548c Continue"},"content":{"rendered":"<p><strong>JavaScript \u7684 break \u548c continue \u8bed\u53e5<\/strong><\/p>\n<p>\u6709\u4e24\u79cd\u7279\u6b8a\u7684\u8bed\u53e5\u53ef\u4ee5\u5728\u5faa\u73af\u4e2d\u4f7f\u7528\uff1a break \u548c continue\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n<strong>Break<\/strong><\/p>\n<p>break \u547d\u4ee4\u7528\u6765\u6253\u65ad\u6574\u4e2a\u5faa\u73af\uff0c \u5e76\u7ee7\u7eed\u6267\u884c\u5faa\u73af\u540e\u9762\u7684\u4ee3\u7801\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u3002<\/p>\n<p><strong>\u4f8b\u5b50<\/strong><\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nvar i=0<br \/>\nfor (i=0;i&lt;=10;i++)<br \/>\n{<br \/>\nif (i==3){break}<br \/>\ndocument.write(&#8220;The number is &#8221; + i)<br \/>\ndocument.write(&#8220;&lt;br \/&gt;&#8221;)<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/table>\n<p><strong>\u7ed3\u679c<\/strong><\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">The number is 0<br \/>\nThe number is 1<br \/>\nThe number is 2<\/td>\n<\/tr>\n<\/table>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n<strong>Continue<\/strong><\/p>\n<p>continue\u547d\u4ee4\u5c06\u6253\u65ad\u5f53\u524d\u8fd9\u6b21\u5faa\u73af\uff0c\u800c\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u4e2a\u5faa\u73af\u503c\u3002<\/p>\n<p><strong>Example<\/strong><\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">&lt;html&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\nvar i=0<br \/>\nfor (i=0;i&lt;=10;i++)<br \/>\n{<br \/>\nif (i==3){continue}<br \/>\ndocument.write(&#8220;The number is &#8221; + i)<br \/>\ndocument.write(&#8220;&lt;br \/&gt;&#8221;)<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/td>\n<\/tr>\n<\/table>\n<p><strong>Result<\/strong><\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">The number is 0<br \/>\nThe number is 1<br \/>\nThe number is 2<br \/>\nThe number is 4<br \/>\nThe number is 5<br \/>\nThe number is 6<br \/>\nThe number is 7<br \/>\nThe number is 8<br \/>\nThe number is 9<br \/>\nThe number is 10<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript \u7684 break \u548c continue \u8bed\u53e5 \u6709\u4e24\u79cd\u7279\u6b8a\u7684\u8bed\u53e5\u53ef\u4ee5\u5728\u5faa\u73af\u4e2d\u4f7f\u7528\uff1a break \u548c continue\u3002 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; Break break \u547d\u4ee4\u7528\u6765\u6253\u65ad\u6574\u4e2a\u5faa\u73af\uff0c \u5e76\u7ee7\u7eed\u6267\u884c\u5faa\u73af\u540e\u9762\u7684\u4ee3\u7801\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u3002 \u4f8b\u5b50 &lt;html&gt; &lt;body&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; var i=0 for (i=0;i&lt;=10;i++) { if (i==3){break} document.write(&#8220;The number is &#8221; + i) document.write(&#8220;&lt;br \/&gt;&#8221;) } &lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt; \u7ed3\u679c The number is 0 The number is 1 The number is 2 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; Continue continue\u547d\u4ee4\u5c06\u6253\u65ad\u5f53\u524d\u8fd9\u6b21\u5faa\u73af\uff0c\u800c\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u4e2a\u5faa\u73af\u503c\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3,"menu_order":10,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/17"}],"collection":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":1,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/17\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/17\/revisions\/241"}],"up":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/3"}],"wp:attachment":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/media?parent=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}