オブジェクト?いいえ.お願いします.


私は物が好きではない。それだけ!


これはオブジェクトです.
const obj = {breed:"labrador",age:9}
しかし、時々、私は配列で働くのを好みます.
なぜ?彼らが本当に私によく見えるので..そして実際にはたくさんのメソッドやループがあります.
これらはオブジェクトを配列に変換するためのツールです.

//Object.values() will give you an array of all the object "values"

const obj = {breed:"labrador",age:9}

const values = Object.values(obj)

console.log(values)

//-> ["labrador", 9]



//Object.keys() will give you an array of all the object "keys"

const obj = {breed:"labrador",age:9}

const keys = Object.keys(obj)

console.log(keys)

//-> ["breed", "age"]



//Object.entries()  will give you an arraysh version of the object. 
//Where the key and the value will be paired into an array... 
//and all of those arrays will be "pushed" into another array.

const obj = {breed:"labrador",age:9}

const entries = Object.entries(obj)

console.log(entries)

//->[["breed", "labrador"], ["age", 9]]


これは簡単なペニーですが、非常によく、私の旅の開始時には、オブジェクトは非常によく私のための問題だった.
彼らが前に私に言ったならば.

P . S :これらのツールはOKです.それがオブジェクトの代わりに配列で働くのがOKならば.
場合によってはオブジェクトを使用する必要があります.パフォーマンスや長期的なメンテナンスのため.