Javascript-how do we understand square brackets described in the syntax in the manual?

Source: Internet
Author: User
When I look up some documents, I often see functionfuncname ([arg1 [, arg2 [..., argn]) {statements} or the rhinoceros varname_1 [value_1] [,..., name_n [value_n]. Similarly, it is often found in the php or css manual... I often see this method when I look up some documents.

In the rhino book
function funcname([arg1 [, arg2 [..., argn]]]){ statements }

Or a rhino book
var name_1 [ = value_1][,..., name_n [= value_n]]

For example, I often see this square brackets in the php or css manuals. How can I understand this square brackets?
Why can't I write it as follows?

function funcname(arg1, arg2, argn){ statements}

var name_1 = value_1, ..., name_n = value_n

Reply content:

I often see this method when I look up some documents.

In the rhino book
function funcname([arg1 [, arg2 [..., argn]]]){ statements }

Or a rhino book
var name_1 [ = value_1][,..., name_n [= value_n]]

For example, I often see this square brackets in the php or css manuals. How can I understand this square brackets?
Why can't I write it as follows?

function funcname(arg1, arg2, argn){ statements}

var name_1 = value_1, ..., name_n = value_n

Square brackets refer to optional parameters, that is, they are optional parameters, and there is no limit on the number. You can enter 0 or N parameters.

Optional parameter. Optional.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.