News for hackers. Stuff that matters.
Re:Args.js – Optional and Default parameters for JavaScript by simon_renoult on Monday January 13, 2014 @10:37AM (#7051139)
Why using :

    function doFoo(bar) {
      bar = (bar !== undefined) ? bar : "default_value";
    }
Over :

    function doFoo(bar) {
      bar = bar || "default_value";
    }
Coercion avoidance ?
Re:Args.js – Optional and Default parameters for JavaScript by dagw on Monday January 13, 2014 @11:12AM (#7051362)
The second function sets bar to "default_value" if called with a falsy argument like 0 or an empty string.
Re:Args.js – Optional and Default parameters for JavaScript by niyazpk on Monday January 13, 2014 @10:54AM (#7051244)
Yes, the second option is better in most cases. I'd spend more time reading the first one to understand what is going on compared to the second option.

Keep in mind that you will have to go for the first option (or other better options) if you expect 'falsy' values to be passed as arguments.

Re:Args.js – Optional and Default parameters for JavaScript by 1wheel on Monday January 13, 2014 @10:47AM (#7051194)
0 is falsy in javascript; with the second method, default_value will get used instead.
Re:Args.js – Optional and Default parameters for JavaScript by elclanrs on Monday January 13, 2014 @12:09PM (#7051840)
I'd use:

  bar = bar != null ? bar : 'default';