function foo(a, b, c) {
// ...
}
foo('a', 'c');
foo('a', null, 'c');
foo('a', 'c');
function foo(name, surname, age) {
if (typeof surname == "number") {
age = surname;
surname = undefined;
}
// ...
}
foo("Ivan", "Ivanov", 23);
foo("Ivan", 23);
function foo(a, b, c) {
if (arguments.length === 2) {
c = b;
b = undefined;
}
// ...
console.log(a,b,c);
}
foo("Ivan", "Ivanov", "Ivanovich");
foo("Ivan", "Ivanovich");