-3

Why is there a comma (i.e., this part "[,") to start the array?

For example, jQuery ajax gives the following: jQuery.ajax( url [, settings ] ). Can someone explain to me why a programmer will implement code like this.

Could it be the index will start at 1 instead of 0 when using this array, so the first item is blank?

First time using stackoverflow. I tried Google and searched multiple sources (including stackoverflow) and I can't find the answer to this. Thanks for the help.

4

1 回答 1

6

It's just a pseudo-syntax in which the brackets indicate an optional argument. Brackets here do not delimit an array. The comma is inside of the brackets as well because the comma is only used if the optional argument is used, like so:

foo(bar[, baz])
// means either
foo(bar)
// or
foo(bar, baz)
于 2013-02-08T05:26:40.540 回答