get data from object using index - JavaScript

 

Object.keys() 

 

Object.key() converts converts object keys in to array. then we can get objecy key using index.

 

const obj = {number: 5, color: 'blue'};

Object.keys(obj)[0]  // number

obj[Object.keys(obj)[0]];  // 5

Tags:

Share:

Related posts