ES6 Rest Parameters - JavaScript Tutorial

preview_player
Показать описание
In this video I'll be taking you through the usage of the Rest Parameters syntax in JavaScript (part of ECMAScript2015/ES6). Very similar to the Spread Syntax, they allow you to pass in an indefinite number of arguments into a function.

Support me on Patreon:

For your reference, check this out:

Follow me on Twitter @dcodeyt!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

Great video. I like how you manage to illustrate concepts with the simplest examples possible while still exactly clarifying how they work.

Guidodo
Автор

With function (...[a, b, c, ]), you can select elements by adding extra commas. (...[a, , , b, c]) would select and pass the 0th, 3rd, and 4th element as a, b, c elements from the supplied array.

DctrSauce
Автор

Damn. I had no idea how cool being able to funnel parameters into arrays directly would be

breborn
Автор

Your explanation is clear and easy to understand. Thank you!

leahpearson
Автор

great explanation: it is easy to understand

ramabookstroremalang
Автор

how are you using nums without defining it?

Michael-ohpy
Автор

I'm here to know more about rest parameters because I am following a React course in which it is used.
The scenario is a component that takes attributes. Some are mandatory and are explicitly asked for, then the ...rest allows to pass as many attributes as needs be.
I don't know how it works in React. Because we are just passing values. The point seems to be this works because the attribute along their respective values share the same name.

EminoMeneko
Автор

where did you get "n" from for the "const n of nums"?

nayru
Автор

Hey @dcode, you have great content. Hope you dont mind if i ask you a question or two? In your first for loop, what is “n of nums” ? I understand that it should be a condition of for loop, but could you explain what “n of nums” means in this case? Thanks ! :)

stefstef
Автор

Thanks for the explanation! Could you please tell me the name of your vscode theme and the font... thanks.

chethankambi
Автор

this is simpler way of summing an array:
return nums.reduce((acc, val) => acc + val);

ubermensch-mne
Автор

Hi how can i get response cookies in ajax ?

mnageh-bomm