Sky
Sky

Reputation: 79

Express.js documentation nested [] meaning?

For example, app.listen method is documented as below, what does the 'host' and 'backlog' nested in the square bracket mean?

app.listen([port[, host[, backlog]]][, callback])

Thank you!

Upvotes: 0

Views: 92

Answers (1)

leumasme
leumasme

Reputation: 390

Square Brackets in general are optional arguments. Nested square brackets like this mean that they are optional, but may only be used if the parent square bracket's argument is also given.

For example, host is optional, but may only be supplied if port is supplied. And also, Backlog is optional, but may only be supplied if host (and port) are given. Callback is outside of these nested Square brackets, and may be supplied or ommited no matter which other arguments are used.

Upvotes: 2

Related Questions