Skip to content

Commit 04b6f1c

Browse files
committed
translate "The for in Loop" in "Object" to ja
1 parent b9fb15e commit 04b6f1c

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

‎doc/ja/object/forinloop.md‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
## The `for in` Loop
1+
## `for in`ループ
22

3-
Just like the `in` operator, the `for in` loop also traverses the prototype
4-
chain when iterating over the properties of an object.
3+
`in`オペレーターは単に、`for in`ループの中でオブジェクトのプロパティをプロトタイプチェーンの中で繰り返し遡る為にあるものです。
54

6-
> **Note:** The `for in` loop will **not** iterate over any properties that
7-
> have their `enumerable` attribute set to `false`; for example, the `length`
8-
> property of an array.
9-
10-
// Poisoning Object.prototype
5+
> **注意:** `for in`ループは`列挙`される属性が`false`にセットされているプロパティを反復処理**しません**。;
6+
> 例えば、配列の`length`プロパティなどがそれに当たります。
7+
8+
// Object.prototype汚染
119
Object.prototype.bar = 1;
1210

1311
var foo = {moo: 2};
1412
for(var i in foo) {
15-
console.log(i); // prints both bar and moo
13+
console.log(i); // barとmooが両方とも表示される
1614
}
1715

18-
Since it is not possible to change the behavior of the `for in` loop itself, it
19-
is necessary to filter out the unwanted properties inside the loop body ,
20-
this is done by using the [`hasOwnProperty`](#object.hasownproperty) method of
21-
`Object.prototype`.
16+
`for in`ループそれ自体の動作を変更する事は不可能ですが、ループ内にある要らないプロパティをフィルタリングする必要があります。そんな時は`Object.prototype`の[`hasOwnProperty`](#object.hasownproperty)メソッドを使うと解決します。
2217

23-
> **Note:** Since the `for in` always traverses the complete prototype chain, it
24-
> will get slower with each additional layer of inheritance added to an object.
18+
> **注意:** `for in`は常にプロトタイプチェーンを完全に遡ります。これにより
19+
> オブジェクトに追加されている継承が多ければ多い程、速度は遅くなります。
2520
26-
### Using `hasOwnProperty` for Filtering
21+
### `hasOwnProperty` for Filtering
2722

2823
// still the foo from above
2924
for(var i in foo) {

0 commit comments

Comments
 (0)