Rest operator in JavaScript

Rest operator is similar to spread operator its an es6 feature that allows converting arguments to an array of values;

Syntax of spread operator is as follows;

function spr(...params) {
    console.log(params)
}

spr(1,2,3)
// [1, 2, 3]

You can use rest operator among other arguments


function sprr(args, ...params) {

    console.log(params)

}

spr('foo', 1, 2, 3)

// [1, 2, 3]


More information:
Rest parameters MDN

Comments

Popular posts from this blog

FlappingBird Postmortem (JS13K)

JavaScript introduction to variables

FlappingBird JS13K Games

How to target all elements of a given class name in JavaScript

Zedplug will be decommissioned on November 30th