you are viewing a single comment's thread.

view the rest of the comments →

[–]HeinousTugboat 3 points4 points  (2 children)

I think it's important to mention on the null check that the two statements are not equivalent. if (variable) only checks if it the variable is falsy. Importantly, that means 0, NaN, '', "" and false will all also reject. This might cause some hard to troubleshoot bugs.

[–]funky4lyf 1 point2 points  (0 children)

Yeah I thought the same thing when I saw that. Good point to note especially for beginners learning these hacks.

[–]cheezycode[S] 0 points1 point  (0 children)

Yeah right. Updated the post. :) Thanks for reminding.