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 JavaScript and the DOM (Retiring) Responding to User Interaction Delaying Execution with setTimeout()

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
228,991 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.