I originally wrote it like this:
function foo(x) {
if(arguments[1]) {
// do something..
} else {
// do other. .
}
}
But no matter how many parameters are passed in, the if(arguments[1]) step is skipped. When I was about to go crazy, I finally succeeded.
function foo(x) {
if(arguments[1] != undefined) {
// do something..
} else {
// do other..
}
}
I remembered that "The Definitive Guide to Javascript" said that sometimes null and undefined are equal, but sometimes they are not equal. This is probably the case.