0

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.

Kid_Learning_C
  • 2,605
  • 4
  • 39
  • 71
  • 1
    It's an optional parameter, which you can but not need to provide. If you don't provide it, some default value (typically described in the docs as well) is used. – derpirscher May 30 '21 at 18:36

1 Answers1

1

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.

Kid_Learning_C
  • 2,605
  • 4
  • 39
  • 71