LoginSignup
16
16

More than 5 years have passed since last update.

JavaScriptで配列の生成

Last updated at Posted at 2014-05-08

空の配列を10個生成

Array.apply(null, {length:10});
> [undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined]

順列の値を含む配列を生成

Array.apply(null, {length:10}).map(Number.call, Number);
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

値を文字列にして生成

Array.apply(null, {length:10}).map(Number.call, String)
> ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16