This course will be retired on October 31, 2026.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introducing ES2015!
You have completed Introducing ES2015!
Preview
Finally we’re able to set default values for function parameters like every other programming language. We’ll review just how simple it is to use.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
If you're familiar with other
programming languages you're probably
0:00
already familiar with the concept.
0:02
You can call a function and
if you don't pass a value for
0:04
certain parameters the function can fill
in those blanks with the default values.
0:07
You can follow along using
the latest workspace by
0:12
launching the workspace on this page.
0:14
Suppose we have a function.
0:16
We'll call it greet.
0:18
It takes two parameters, name and time of
day, and it logs a message to the console.
0:19
Now in ES5, we could check the arguments
passed into the function and
0:25
set default values.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up