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
Post a Comment