Rest Arguments: The rest parameter syntax allows you to pass a variable number of arguments to a function. This is useful when you want to handle multiple arguments without explicitly listing them. The spread syntax is used to pass multiple values from an iterable (like an array) as individual arguments to a function.
const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];
arr1.push(…arr2);
In this example, the push
method takes any number of arguments using the spread syntax, allowing you to push the elements of arr2
into arr1
.