Javascript rest parameters

// collects parameters and turns them into an array
// must be the last parameter
// no IE support
// no Safari support

function writeArguments(name, ...values) {
console.log(`my name is ${name}`);
console.log(JSON.stringify(values)); // [1,2,3]

writeArguments("john doe", 1, 2, 3);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s