How to access an object property with a hyphen in TypeScript

1 Answer

0 votes
const obj = {
  'lang-1': 'typescript',
  'lang-2': 'c',
  'lang-3': 'python',
};
  
console.log(obj['lang-1']);
console.log(obj['lang-2']);
console.log(obj['lang-3']);
 
      
     
     
     
/*
run:
     
"typescript" 
"c"
"python"
     
*/

 



answered May 14, 2022 by avibootz

Related questions

1 answer 132 views
1 answer 113 views
1 answer 123 views
1 answer 137 views
1 answer 134 views
1 answer 135 views
...