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 222 views
1 answer 242 views
1 answer 214 views
1 answer 216 views
1 answer 224 views
1 answer 230 views
1 answer 222 views
...