Why arguments in all JavaScript Documentation are written like this? [duplicate]

Square brackets are used by a lot of programming environments, command line tools and documentation to show that arguments are optional.

The double brackets mean that supplying one of the optional arguments doesn’t force you to provide a value for the others.

That means that replacer is optional, and if you provide it, space is optional again, and that you can’t specify space without specifying replacer.

This opposed to: (sample)

JSON.stringify(value[, replacer, space])

Where you need to provide a value for space if you provide a value for replacer.

Leave a Comment