How to get an object key by index in TypeScript

1 Answer

0 votes
const obj = {
  id: 849731,
  name: "tom",
  language: "typescript"
};
  
console.log(Object.keys(obj)[0]); 
console.log(Object.keys(obj)[1]); 

    
      
      
      
/*
run:
      
"id"
"name"
      
*/
     

 



answered May 28, 2022 by avibootz

Related questions

1 answer 162 views
1 answer 135 views
2 answers 106 views
1 answer 133 views
1 answer 138 views
1 answer 121 views
...