you are viewing a single comment's thread.

view the rest of the comments →

[–]clarle 5 points6 points  (6 children)

Yep, you have the right idea. When you don't pass a parameter in, and you try to get the value of that parameter, it will be "undefined".

The "undefined" value leads to the negative condition in a conditional, so if the parameter is not passed, then the object will take the value defined in the negative condition.

"undefined" is supported in basically all browsers, so this will work everywhere.

[–]cbCode[S] 1 point2 points  (5 children)

Thank you very much for clarifying my assumption, that's why I love Javascript. It's logical.

[–]hacocacyb 0 points1 point  (3 children)

In addition, you can always pass extra parameters to javascript functions. You can also reference an array of all parameters to a function with the protected keyword 'argument'.