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);

Comments

Popular posts from this blog

C# Record Serialization

Add timestamp to photo using ImageMagick

Read/write large blob to SQL Server from C#