0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Javascript備忘録] Array(times)と[..Array(times)]の違い

Last updated at Posted at 2023-06-03

Array(times)timesを要素数の上限とした配列を作る。あくまで上限の話なので、実際の要素数は0個。

Array(4) [ <4 empty slots> ]
  length: 4

[...Array(times)]times個の要素を実際に持った配列を作る

Array(4) [ undefined, undefined, undefined, undefined ]
  0: undefined
  1: undefined
  2: undefined
  3: undefined
  length: 4

したがって
Array(times).map()は0回ループ
[...Array(times)].map()times回ループ

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?