Skip to content
loading...

Get Object's Keys and Values The Easy Way

twitter logo github logo ・1 min read  

By using Object methods keys(), values(), and entries(), you can get an array containing object's keys, values, and key values arrays respectively.

Mithilfe der Objektmethoden keys (), values ​​() und entries () können Sie ein Array abrufen, das die Schlüssel, Werte und Schlüsselwert-Arrays des Objekts enthält.

Here is the syntax👇

const obj = {
    name: 'codehood',
    type: 'channel'
};

//Get array of object keys
Object.keys(obj); // ['name', 'type']

//Get array of onject values 
Object.values(obj); // ['codehood', 'channel']

//Get array of key/value arrays
Object.entries(obj); 
// [['name', 'codehood'], ['type', 'channel']]

👉Follow me on Twitter: https://twitter.com/islam_sayed8

twitter logo DISCUSS
Classic DEV Post from May 29 '19

Is generalization killing creativity in the software industry?

As software gets more and more integrated into our lives, the industrialization of its crafting process becomes inevitable. But the over-generalization of software engineering can be crushing the creative side of programming.

Islam Sayed profile image
A Freelance Front-End Web Developer, tech writer, and mentor at Udacity.
Sign up (for free)

dev.to is where software developers stay in the loop and avoid career stagnation.