Explore variable numbers of arguments and default values.
- [Instructor] In this video we're going to look…at arguments and functions a little more and see…how you can have functions with variable numbers…of arguments and how you can provide default…values for arguments that you want to be optional.…First, I'm going to show this function…that I've defined called speakSomething.…And it takes two arguments.…Your functions don't have to have only one argument.…They can have as many as you want.…So anyway, speakSomething takes two.…It takes what to say.…We'll pass in hey, hey.…And how many times to say it?…We'll go with five.…
And so when I call this, it says, "Hey, hey,"…and it tells me how many times it's said it…so far starting with zero.…So you can see this works fine.…You can have more than one argument…in your functions, but what if say you want…to provide default values for some of these.…So what if I know that I want to say, "Hey, hey,"…but I don't care how many times I said it?…I can let the function do that for me and that works fine.…In this case, the default value is 10, so it goes 10 times.…
- Using a text editor
- Declaring and assigning variables
- Booleans and the quest for truth
- Working with objects and arrays
- Using operators and control structures
- Iterating with loops
- Objects, references, and functions
- Promises, async, and await
Skill Level Beginner
1. Getting Started
2. Variables and Types
3. Objects, Arrays, and More
4. Operators and Control Structures
5. Iterating with Loops
7. More Advanced Pieces
Next steps3m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.