DEV Community

Cover image for Get Object's Keys and Values The Easy Way

Get Object's Keys and Values The Easy Way

islam profile image Islam Sayed ・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
// [['name', 'codehood'], ['type', 'channel']]

👉Follow me on Twitter:

Discussion (0)

Editor guide