Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

JavaScript - Rest parameters

Rest parameters is denoted by three dots ...

It is used to represent an indefinite number of arguments as an array.

It allows you to pass a varying number of arguments to a function without explicitly defining them as individual parameters.

  • Syntax:
    const sum = (...scores) => {
        scores.forEach(() => {
            // statement
        });
    };
    
    sum(1, 2, 3, 4, 5, 6);