ES6 Lesson #5 - Function parametres

There are a lot of interesting innovations in es6 for working with function parameters. The first of these is the standard values ​​of the variables.

For example:

function callValera(name = "Corova", phone = "Valera has no phone") {
  console.log(name + "; " + phone)
}

callValera() // returns "Corova; Valera has no phone"

Now you don’t have to create thousands of conditions, use standard values

But what if we don’t know how many parameters are passed to the function, but we need to get them all? We can use reservated variable arguments, but then you have to write array.prototype, which no one needs anymore, since es6 has the remaining options.

function letValeraGo(...values) {
  console.log(values); // returns array [25, "valera", "its so valera"]
}

letValeraGo(25, "valera", "its so valera");