1
1

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

まさかのGASで悩まされたこと

Last updated at Posted at 2019-01-21

constやletにするとエラーは起きないけど
なぜか配列のデータがindex[0]しか取り出せなかった。

  const array = ["a", "b", "c", "d"]
  for (let index = 0; index < array.length; index++) {
    const value = array[index];
    Logger.log(value)
  }

####出力結果

a
a
a
a

全部、varに変更したら問題なく全部取り出せた。

  var array = ["a", "b", "c", "d"]
  for (var index = 0; index < array.length; index++) {
    var value = array[index];
    Logger.log(value)
  }

####出力結果

a
b
c
d

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?