Skip to content
Akin C edited this page Nov 3, 2017 · 20 revisions

Welcome to the Javascript-use-of-apply- wiki!

This repository is part of a larger project!


The Javascript apply method is similar to the method call.

The big difference is the ability of apply to take an array of arguments.

This is important for example variadic functions or also known as variable-arity functions. An example for a variadic function could be one which calculates the sum of a series of numbers:

//Variadic Function
function calculateSum(listOfNumbers)
{
    var sum = 0;
  
    for(var i = 0; i < listOfNumbers.length; i++)
    {
        sum+=listOfNumbers[i];
    }
  
    return sum;
}

//Outputs Sum
calculateSum([1,2,3]);

STILL IN WORK!!!

Clone this wiki locally