... it's safe to assume that it will never evaluate to a falsy value.
No, it's not safe. If you'd have an object like {'a': 1, 'b': 2, 'c': 0}
, objs[i].c
will be evaluated falsy. (Or c
equals to false
, NaN
, null
, undefined
or ''
.)
If you want just to know, if there's a property defined in an object, you can do 'c' in objs[i]
, but beware, this will also include properties from the prototype chain.
If you want to avoid getting properties from the prototype chain, hasOwnProperty
check needs to be done.
There's also Object.keys
available in modern browsers, though it's not handy on quick-checks.