Skip to content

Latest commit

 

History

History
15 lines (10 loc) · 741 Bytes

TIPS.md

File metadata and controls

15 lines (10 loc) · 741 Bytes

Tips

Protecting from inexistent properties, when testing property values

Prefer the in operator — which will return true for a property with a value of false or undefined

"isPending" in userResource && userResource.isPending === false

… instead of the dot property accessor — which would short-circuit the evaluation, when a property was defined, but holds either an undefined or a false value, because both are falsy boolean values:

userResource.isPending && userResource.isPending === false