News for hackers. Stuff that matters.
Re:Default Parameters in JavaScript by noonat on Tuesday March 19, 2013 @11:49AM (#5401582)
If you want to allow undefined to be passed as a valid non-default value for a trailing parameter, you can also use arguments.length to determine how many arguments were explicitly specified.

    var foo = function(a, b) {
        if (arguments.length < 2) {
            b = 'some default value';
        }
        // ...
    };
Re:Default Parameters in JavaScript by ajanuary on Tuesday March 19, 2013 @01:19PM (#5402215)
I wish jQuery's setter methods worked this way. It's too easy to accidentally turn a setter into a getter.