mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 14:36:22 +00:00
484 B
484 B
id | title |
---|---|
4236e165-bf8b-45fd-9a4c-6cbb66916c45 | JavaScript Rest Parameters |
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)