Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Xinyu (Sean) Zhang
PLUS
Xinyu (Sean) Zhang
Courses Plus Student 7,064 Points

the getData takes twoParam and the firstParam is an object which has two properties. what is equal sign and {} following

In this video, the function getData takes two parameters and the first parameter is an object which has two properties. what is that equal sign and {} following the object?

1 Answer

Steven Parker
Steven Parker
229,966 Points

An equal sign in a parameter description establishes a default value for that parameter to be used if none is supplied when the method is called. And a pair of braces represent an empty object, so the entire expression means "if no parameter is given, use an empty object as the parameter".