search

Home  >  Q&A  >  body text

javascript - In the parameter description in the js document, get(url[, config]) or get(url,[config]) will appear. What is the difference?

For example, in the axios documentation

axios#get(url[, config])

axios#delete(url[, config])

axios#head(url[, config])

get(url[,config]) The config parameter indicates optional
get(url,[config]) This config also indicates optional, both are What's the difference? How to write the comma inside
and the comma behind it:
jquery:
hover([over,]out) and hover([over] ,out) What’s the difference?
This kind of comma is at the end, and the square brackets also indicate optional
Where is this syntax or writing specification defined? How can I find this way of writing? What about the description

怪我咯怪我咯2797 days ago711

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-19 10:44:06

    I haven’t read the documentation of axios.

    My understanding is:
    get(url[, config])This representation can write two parameters or one parameter, the latter one is optional; get(url[, config])这种表示可以写两个参数或一个参数,后一个是可选的;
    get(url,[config])这种表示必须写两个参数,后一个config虽然可选,但是没有的时候要传null;
    hover([over,]out)这种表示你写两个参数的时候分别作为over和out传进函数,而如果只有一个参数那就是out;
    hover([over],out)get(url,[ config])This representation must write two parameters. Although the latter config is optional, null must be passed if it is not available;

    hover([over,]out)This representation When you write two parameters, pass them into the function as over and out respectively, and if there is only one parameter, it is out;

    hover([over],out) The meaning is the same as above: it must be passed when there is no over Enter null;

    🎜Nowadays, most plug-ins can recognize the number of parameters, so it seems that there are very few cases where commas are written outside and null placeholders need to be passed. 🎜

    reply
    0
  • Cancelreply