Monday, July 18, 2016

JavaScript - Arguments

JavaScript function without defining parameters

function add() {
    var result = 0;
    for (var i = 0; i < arguments.length; i++) {
        result = result + arguments[i];
    }
    return result;
}


Result :
> add(3,7,8,10)
28

No comments: