summaryrefslogtreecommitdiffhomepage
path: root/javascript.html.markdown
diff options
context:
space:
mode:
authorYi Hong Ang <ang.yi.hong@gmail.com>2016-10-31 07:33:22 +0800
committerven <vendethiel@hotmail.fr>2016-10-31 00:33:22 +0100
commit6d351553ac83f08d8ad784c57740ddc43899859c (patch)
tree1b8b466132d1f4d3432dc68af30456d03b6b1abd /javascript.html.markdown
parenta98cc99ef7601ae6e27960563f5b8b73953b25c7 (diff)
add labeled loop breaking for Javascript (#2539)
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r--javascript.html.markdown11
1 files changed, 11 insertions, 0 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 98261334..38119864 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -230,6 +230,17 @@ for (var i = 0; i < 5; i++){
// will run 5 times
}
+// Breaking out of labeled loops is similar to Java
+outer:
+for (var i = 0; i < 10; i++) {
+ for (var j = 0; j < 10; j++) {
+ if (i == 5 && j ==5) {
+ break outer;
+ // breaks out of outer loop instead of only the inner one
+ }
+ }
+}
+
// The for/in statement iterates over every property across the entire prototype chain.
var description = "";
var person = {fname:"Paul", lname:"Ken", age:18};