What do the brackets around the arguments mean when reading the documentation for the method?

Often when reading documentation about which arguments can be passed to a method, I see the brackets used in the argument list as follows:

example of brackets used within arguments on method documentation

What do parentheses mean in this context? Why are commas inside brackets?

+6
source share
3 answers

required [optional] <required> [<optional>, <but both needed>] .

This is almost always the case.

+10
source

The brackets around the parameter mean that this is optional.

When writing separately, this means that you can use any of the parameters in any combination. The method determines what you are using from the data type of the values. All of these combinations can be used for this method:

 .animate(properties, duration, easing, complete) .animate(properties, duration, easing) .animate(properties, duration, complete) .animate(properties, duration) .animate(properties, easing, complete) .animate(properties, easing) .animate(properties, complete) .animate(properties) 

You can see the brackets used in other ways than around each parameter. For instance:

 .method(p1 [, p2 [, p3]]) 

This means that the second and third parameters are optional, and the third parameter can only be used if there is a second parameter.

+2
source

Square brackets mean they are optional parameters. You do not have to pass optional parameters. .animate(properties) will work. In addition, the commas are inside the brackets, because if they were outside, they would follow

animate (properties, [duration]) will mean properties and are mandatory, whereas duration is not ... He would like: animations (properties)

0
source

All Articles