use a default value if the parameter is omitted:
if (typeof optionalArg === 'undefined') {
optionalArg = 'default';
}
Reference:
http://stackoverflow.com/questions/148901/is-there-a-better-way-to-do-optional-function-parameters-in-javascript
if (typeof optionalArg === 'undefined') {
optionalArg = 'default';
}
No comments:
Post a Comment