Kid_Learning_C
Kid_Learning_C

Reputation: 3603

what does "[," mean in the syntax for describing input parameters format?

This is a rookie question but I couldn't find the name / keyword for this kind of syntax that is widely used in describing input parameters formats. For example:

Request method aliases
For convenience aliases have been provided for all supported request methods.

axios.request(config)
axios.get(url[, config])
axios.delete(url[, config])
axios.head(url[, config])
axios.options(url[, config])
axios.post(url[, data[, config]])
axios.put(url[, data[, config]])
axios.patch(url[, data[, config]])

The syntax url[, config] or url[, data[, config]] just looks really strange and is not self explanatory. What is the name for this kind of syntax?

I've seen them widely used but not sure how to read them. I just need someone to point a direction and tell a keyword / name or two about this syntax.

Upvotes: 0

Views: 37

Answers (1)

Kid_Learning_C
Kid_Learning_C

Reputation: 3603

Answering myself here in case anyone had the same confusion:

whatever goes in [] is optional. For example:

The expression of axios.get(url[, config]) means that:

  1. axios.get(url) is acceptable, and

  2. axios.get(url, config) is also acceptable.

Upvotes: 1

Related Questions