From the course: Learning the JavaScript Language
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Three little dots collect the rest - JavaScript Tutorial
From the course: Learning the JavaScript Language
Three little dots collect the rest
- [Instructor] In our efforts to become conversant in JavaScript, there's a bit of newer syntax that we might see that's going to appear a little bit mysterious. It looks like an ellipses, but it's actually three dots typed as three periods or full stops in the parenthesis of a functions declaration. This is called rest parameters, and the result is an array of arguments. Previously, we've seen the array like object called arguments but this is an actual JavaScript array. So along with the length property it has all the methods that regular arrays have for sorting and otherwise manipulating the items. That might not be something you'll put into use very often but it's good to know. Here's the adding machine function we saw previously rewritten to use rest parameters. Because it's the only parameter in the function, all arguments are captured in terms here and can be looped over just like we did previously with the…
Contents
-
-
-
-
-
-
-
-
(Locked)
Basic functions4m 20s
-
(Locked)
Arguments and parameters in functions6m 54s
-
(Locked)
More on function arguments5m 3s
-
(Locked)
Objects, references, and functions7m 4s
-
(Locked)
Functions are objects5m 8s
-
(Locked)
Jargon: Scope in JavaScript2m 30s
-
(Locked)
Functions and scope5m 11s
-
(Locked)
Writing shorter functions with arrows3m 12s
-
(Locked)
Three little dots collect the rest4m 14s
-
(Locked)
Callback functions and looping4m 34s
-
(Locked)
-
-