2
2

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 3 years have passed since last update.

動的な配列って何?

Last updated at Posted at 2020-04-03

プログラミングスクールでチーム開発をする際に、

参考にした記事のコードでこの一文で結構悩まされたので

メモに書いときます。


let fileIndex = [1,2,3,4,5,6,7,8,9,10];
fileIndex.shift();

console.log(fileIndex);
//9[2,3,4,5,6,7,8,9,10]
fileIndex.push(fileIndex[fileIndex.length - 1] + 1)
//計算の順番に並べてます
//fileIndex.push(fileIndex[9 - 1] + 1)
//fileIndex.push(fileIndex[8] + 1)
//2,3,4,5,6,7,8,9,10 ←この数字を取り出す
//0,1,2,3,4,5,6,7,[8番目] 配列の順番は下の文になります。
//↓そのために
//10
//fileIndex.push(10 + 1)
//fileIndex.push(11)
consol.log(fileIndex);
10[2,3,4,5,6,7,8,9,10,11]

fileIndex.push(fileIndex[fileIndex.length - 1] + 1)

一文だけにこんなに時間を使うとはは思いませんでした。

2
2
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?