DEV Community

Dillon
Dillon

Posted on

A Kafka Object Metamorphizes Into An Array

Object.keys

  • This pulls the keys of an object and puts them into an array. for ex.

{flavor: cherry,
price: 12.99,
size: large}
Object.values
Object.entries

Top comments (1)

Collapse
 
dillpap profile image
Dillon

Set is helpful if you want to return unique values from an array.

if you had an array of people's favorite pokemon, and you wanted to see how many unique Pokemon there were... numbers const pokePals = ["Lapras", "Wartortle", "Gyrados", "Dragonair", "Gyrados", "Kingdra", "Lapras", "Bulbasaur"];

If you wanted a list that showed all the Pokemon that had favorite votes without seeing duplicates,

const favs = [...new Set(pokePals)];