How to check if key exists in object with Node.js

2 Answers

0 votes
const obj = {
  	nodejs: true,
  	php: false,
  	cpp: true,
  	python: false
};
 
console.log("nodejs" in obj);
 
   
     
     
/*
run:
     
true
     
*/

 



answered Jul 13, 2022 by avibootz
0 votes
const obj = {
  	nodejs: true,
  	php: false,
  	cpp: true,
  	python: false
};
 
console.log(obj.c ? "Yes" : "No");
 
   
     
     
/*
run:
     
No
     
*/

 



answered Jul 13, 2022 by avibootz

Related questions

1 answer 145 views
2 answers 167 views
1 answer 163 views
1 answer 167 views
2 answers 1,146 views
1 answer 227 views
...