Usually, when working with functions with JavaScript, the parameters that you pass into the function would be fixed in numbers. function updateUser(name, age) { console.log(name, age); } updateUser('Cherika', 5); Here, as you can tell, the updateUser function accepts two parameters, and these parameters are fixed.

But there may be a certain situation where you would need a variable number of parameters. For instance, when accepting postal addresses from the user, the street, city, and state might be fixed.

function saveAddress(street, city, state) { console.log(street, city, state); } saveAddress('123 Street', 'NYC', 'New York'); But let’s say you want to collect more information regarding the address (like address 1, zip code, and country) without allocating a parameter for each of these fields.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners