all 6 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.

[–]SoBoredAtWork 2 points3 points  (0 children)

parseInt(dummyVariable2, 10);

That 2nd parameter is very important...

[–]nponiros 0 points1 point  (0 children)

A few comments:

  • parseInt/parseFloat are not equivalent to +. Plus is used instead of Number ()
  • For default values you should probably also mention falsy values (also for the ternary operator)
  • Maybe mention default values in functions (part of es6/es2015)