0

I've seen this a lot and most of the time I can figure out what it means, but there have been times when I was a bit confused. Looking at documentation mostly on jquery i see something like this:

.toggleClass( function [, state ] )

what does the bracket notation with the comma and state mean exactly?

Any info would be awesome.

Thanks!

Kobby
  • 43
  • 1
  • 5

2 Answers2

3

Everything between the brackets [] is optional.

In your case it means that state can be omitted, and the function will still work.

Ori Drori
  • 183,571
  • 29
  • 224
  • 209
1

Optional parameters.

Those marked inside such as state in your case can be omitted and the function will not throw an error.

For another example:

jQuery.ajax( url [, settings ] )

Means both

jQuery.ajax( "www.google.com" )

and

jQuery.ajax( "www.google.com" , {dataType: 'mycustomtype'} )

are valid.

Iceman
  • 6,035
  • 2
  • 23
  • 34