mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
add for/of to js
This commit is contained in:
parent
8612e00b9f
commit
faca0e7944
@ -248,6 +248,13 @@ for (var x in person){
|
|||||||
description += person[x] + " ";
|
description += person[x] + " ";
|
||||||
} // description = 'Paul Ken 18 '
|
} // description = 'Paul Ken 18 '
|
||||||
|
|
||||||
|
// The for/of statement allows iteration over an iterator.
|
||||||
|
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
|
// && is logical and, || is logical or
|
||||||
if (house.size == "big" && house.colour == "blue"){
|
if (house.size == "big" && house.colour == "blue"){
|
||||||
house.contains = "bear";
|
house.contains = "bear";
|
||||||
|
Loading…
Reference in New Issue
Block a user