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

ES2022で追加された便利そうな機能

Last updated at Posted at 2022-12-17

配列の最後を取得できるat()

引数にマイナス値を指定すれば、配列の末尾から参照してくれる

const array = [1,2,3]
console.log(array.at(-1)) // 3

こう書かなくてよくなった

console.log(array.at(array.length - 1)) // 3

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