MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/21ezh3/javascript_equality_table/cgcr9oe/?context=3
r/programming • u/vz0 • Mar 26 '14
331 comments sorted by
View all comments
0
So I'm currently doing this in a lot of places:
if (obj.x !== undefined && obj.x) { // do something }
because
if (obj.x) { //do something }
throws an error if obj.x is undefined.
Anyone know of a better way?
3 u/dscer Mar 26 '14 if (obj && obj.x) { // do something }
3
if (obj && obj.x) { // do something }
0
u/optymizer Mar 26 '14
So I'm currently doing this in a lot of places:
because
throws an error if obj.x is undefined.
Anyone know of a better way?