How to check whether a Javascript object has a value for a given key? [duplicate]
if (‘X’ in mmap) { // … } Here is an example on JSFiddle. hasOwnProperty is also valid, but using in is much more painless. The only difference is that in returns prototype properties, whereas hasOwnProperty does not.