Javascript Function Overloading Optional Arguments with Default Values

Description

Javascript Function Overloading Optional Arguments with Default Values

// An concise approach for optional argument default-values
function addFiveNumbers(a,b,c,d,e) {
    a = a || 0;//from w w w  .  j a  v  a2  s  .c om
    b = b || 0;
    c = c || 0;
    d = d || 0;
    e = e || 0;  
    return a + b + c + d + e;
}



PreviousNext

Related