How to access an object property with a hyphen in Node.js

1 Answer

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

 



answered May 14, 2022 by avibootz

Related questions

1 answer 131 views
1 answer 145 views
1 answer 121 views
1 answer 128 views
1 answer 131 views
1 answer 135 views
1 answer 133 views
...