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 149 views
2 answers 171 views
1 answer 165 views
1 answer 171 views
2 answers 1,151 views
1 answer 228 views
...