Add missing terminators + other corrections (#23502)
* Add missing terminators + other corrections Missing terminators were added and for loop formatting was corrected. Even though terminators are optional, they can often confuse beginners. Also, a typo and a grammatical error was corrected. * fix: formatting
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
---
|
---
|
||||||
title: For...In Loop
|
title: For...In Loop
|
||||||
---
|
---
|
||||||
The `for...in` statement iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
|
The `for...in` statement iterates over the enumerable properties of an object, in an arbitrary order. For each distinct property, statements can be executed.
|
||||||
|
```js
|
||||||
for (variable in object) {
|
for (variable in object) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
| Required/Optional | Parameter | Description |
|
| Required/Optional | Parameter | Description |
|
||||||
|-------------------|-----------|----------------------------------------------------------------------|
|
|-------------------|-----------|----------------------------------------------------------------------|
|
||||||
@@ -15,12 +16,12 @@ The `for...in` statement iterates over the enumerable properties of an object, i
|
|||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
```js
|
||||||
// Initialize object.
|
// Initialize object.
|
||||||
a = { "a": "Athens", "b": "Belgrade", "c": "Cairo" }
|
var a = { "a": "Athens", "b": "Belgrade", "c": "Cairo" };
|
||||||
|
|
||||||
// Iterate over the properties.
|
// Iterate over the properties.
|
||||||
var s = ""
|
var s = "";
|
||||||
for (var key in a) {
|
for (var key in a) {
|
||||||
s += key + ": " + a[key];
|
s += key + ": " + a[key];
|
||||||
s += "<br />";
|
s += "<br />";
|
||||||
@@ -65,7 +66,7 @@ The `for...in` statement iterates over the enumerable properties of an object, i
|
|||||||
// a
|
// a
|
||||||
// b
|
// b
|
||||||
// c
|
// c
|
||||||
|
```
|
||||||
# Ohter Resources:
|
## Other Resources:
|
||||||
* [MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)
|
* [MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)
|
||||||
* [MSDN link](https://msdn.microsoft.com/library/55wb2d34.aspx)
|
* [MSDN link](https://msdn.microsoft.com/library/55wb2d34.aspx)
|
||||||
|
Reference in New Issue
Block a user