summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-09-08 17:08:04 +0530
committerGitHub <noreply@github.com>2018-09-08 17:08:04 +0530
commitd27199d0012866f0b7da8ffeca9a7f10dc284c25 (patch)
tree0443ceed97fb0387d349a11ea5920ad4638f95d2
parent0ae2fc7c6d1ab4e47544f8339df37857797fee6b (diff)
parent2a3d19ef73cf273e5ab0b0a6d640172b47b6bb92 (diff)
Merge pull request #3148 from hamidra/hamid/js
[javascript/en] add for/of loops
-rw-r--r--javascript.html.markdown9
1 files changed, 9 insertions, 0 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 52084e93..ecaf02c5 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -266,6 +266,15 @@ for (var x in person){
description += person[x] + " ";
} // description = 'Paul Ken 18 '
+// The for/of statement allows iteration over iterable objects (including the built-in String,
+// Array, e.g. the Array-like arguments or NodeList objects, TypedArray, Map and Set,
+// and user-defined iterables).
+var myPets = "";
+var pets = ["cat", "dog", "hamster", "hedgehog"];
+for (var pet of pets){
+ myPets += pet + " ";
+} // myPets = 'cat dog hamster hedgehog '
+
// && is logical and, || is logical or
if (house.size == "big" && house.colour == "blue"){
house.contains = "bear";