最終更新:2022-09-16 (金) 18:59:44 (20d)  

Object.entries
Top / Object.entries

引数に与えたオブジェクトが所有する、文字列をキーとした列挙可能なプロパティの組 [key, value] からなる配列を返します

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

メモ

  • var data = {id:123,name:"abc"};
    console.dir(Object.entries(data))
    >Array(2)
    >  0: (2) ['id', 123]
    >  1: (2) ['name', 'abc']
    >  length: 2
    >  [[Prototype]]: Array(0)
var data2 = {1:{id:123,name:"abc"}};
console.dir(Object.entries(data2))
>Array(1):
>  0: (2) ['1', {…}
>     0: "1"
>     1: {id: 123, name: 'abc'}
>  length: 1
>  [[Prototype]]: Array(0)