Answer the question
In order to leave comments, you need to log in
What's not kosher about the if (!item.x) check?
Ran diagonally across: stackoverflow.com/questions/135448/how-do-i-check-... but the question remains unclear.
There are several ways to check that the var item = { foo: 'bar' } object does not contain the x key:
if (!item.x)
if (!item['x'])
if (typeof item['x'] === 'undefined')
if (!('x' in item)) // кошерно
if (!item.hasOwnProperty('x')) // кошерно (плюс исключает наследуемые x)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question