How do I check if an object has a key in JavaScript? [duplicate]
This question already has answers here: How do I check if an object has a specific property in JavaScript? (30 answers) Closed 8 years ago. Which is the right thing to do? if (myObj[‘key’] == undefined) or if (myObj[‘key’] == null) or if (myObj[‘key’]) 2 Try the JavaScript in operator. if (‘key’ in myObj) And … Read more