Skip to content

Commit d07447e

Browse files
committed
translate "The Array Constructor" in "Array" to ja
1 parent 5036ba6 commit d07447e

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

‎doc/ja/array/constructor.md‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
## The `Array` Constructor
1+
## `Array`コンストラクター
22

3-
Since the `Array` constructor is ambiguous in how it deals with its parameters,
4-
it is highly recommended to always use the array literals - `[]` notation -
5-
when creating new arrays.
3+
`Array`コンストラクターはそのパラメーターの扱い方が曖昧なので、新しい配列を作る時には、常に配列リテラル - `[]`記法 - を使用する事を強くお勧めします。
64

7-
[1, 2, 3]; // Result: [1, 2, 3]
8-
new Array(1, 2, 3); // Result: [1, 2, 3]
5+
[1, 2, 3]; // 結果: [1, 2, 3]
6+
new Array(1, 2, 3); // 結果: [1, 2, 3]
97

108
[3]; // Result: [3]
11-
new Array(3); // Result: []
12-
new Array('3') // Result: ['3']
9+
new Array(3); // 結果: []
10+
new Array('3') // 結果: ['3']
1311

14-
In cases when there is only one argument passed to the `Array` constructor,
15-
and that argument is a `Number`, the constructor will return a new *sparse*
16-
array with the `length` property set to the value of the argument. It should be
17-
noted that **only** the `length` property of the new array will be set this way,
18-
the actual indexes of the array will not be initialized.
12+
このケースの場合、`Array`コンストラクターに渡される引数は一つだけですが、その引数は`Number`になります。コンストラクターは、引数に値がセットされた`length`プロパティを伴った新しい*疎*配列を返します。特筆すべきなのは、新しい配列の`length`プロパティ**のみ**が、このようにセットされるという事です。実際の配列のインデックスは初期化されません。
1913

2014
var arr = new Array(3);
2115
arr[1]; // undefined
22-
1 in arr; // false, the index was not set
16+
1 in arr; // false, インデックスがセットされていない
2317

24-
The behavior of being able to set the length of the array upfront only comes in
25-
handy in a few cases, like repeating a string, in which it avoids the use of a
26-
`for loop` code.
18+
配列の長さが先行してセットされるという振舞いは、いくつかの場合に便利です。例えば、文字の繰り返しや、`for loop`を使用したコードの回避などの場合です。
2719

2820
new Array(count + 1).join(stringToRepeat);
2921

0 commit comments

Comments
 (0)