Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction Delaying Execution with setTimeout()

Amandeep Pasricha
Amandeep Pasricha
14,932 Points

Shouldn't greetings and the delay number have gone inside (something)?

With arrow notation--> if we have multiple arguments, then, of course, we write the arguments down in the parenthesis in the beginning. In this case, the arguments would be written along with something.

In the doc, it looked like the delay value as well as the other parameters were arguments of the function. If so, why did he write such values outside of the arrow functIon then?

That's why I got confused with the format he was writing this in.

On the page, it writes like this--> var timeoutID = scope.setTimeout(function[, delay, param1, param2, ...]); So why didn't param1 and param2, and delay go inside of (something). The sqaure brackets after the function look like arguements of the function.

1 Answer

Steven Parker
Steven Parker
216,688 Points

What you see in the syntax portion of the documentation are not code examples. Square brackets in that area are used to indicate that what the terms inside describe is optional.

In this case, they are telling you that the first argument to "setTimeout" will be a function, and there may be other arguments. If so, the next will be a delay, then maybe a value, and so on.