Introduction

Introduced in ES6

Syntax

function logAllArguments(...args) {
    for (const arg of args) {
        console.log(arg);
    }
}
 
logAllArguments(1, 2, 3)
function logAllArguments(pattern, ...args) {
    console.log(pattern)
    for (const arg of args) {
        console.log(arg);
    }
}
 
logAllArguments("asdf", 1, 2, 3)