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 1 year has passed since last update.

javascriptのObject.entriesについて

Posted at

Object.entriesとは

オブジェクトを配列に変換するメソッド
基本文法は以下の通りです。

javascript
Object.entries(obj)

上記の文法を利用すると、オブジェクトが配列に変わるらしいので、実際にやっています。

オブジェクトと配列に変換

javascript
const obj = { "a": 1, "b": 2, "c": 3 }
const result = Object.entries(obj)
console.log(result) // [["a", 1], ["b", 2], ["c", 3]] 

上記のようにobjのオブジェクトが配列に変わる。
keyとvalueが一つの配列になり、それらを含むすべての配列を返す。
これが、Object.entriesの大きい働きである。

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?