From the course: Learning the JavaScript Language
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
More on function arguments - JavaScript Tutorial
From the course: Learning the JavaScript Language
More on function arguments
- [Presenter] In this video, we're going to look at arguments and functions a little more. We'll see how to define functions with variable numbers of parameters and how to make arguments optional by defining default values for them. First, I'm going to show this function I've defined called speak something. I've pasted in the code defining function ahead of time so we can look at how it works before we actually see that code, which takes two arguments. Your functions don't have to have only one. They can have as many arguments as you need. Speak something can take two arguments. It takes what to say like good morning and how many times to say it as a second parameter. Five times in this case. And when I call this, it says good morning and also tells me how many times it has said it so far. So you could see that you can have more than one argument, but what if you want to provide default values for some of these? What if I know that I want to say good morning, but I don't care how many…
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)
-
-