Understand examples better

Reading about JavaScript methods on the MDN. I realized that I don’t understand what something means. This is the page I was reading. I would like to know what the brackets mean in the example they give at the top? Why is the comma inside the brackets? Is this just saying that something is optional? Is there any more significance than that? Thanks

You’ve interpreted that correctly. If you read further down, it does explain that the second parameter is optional. The examples a little way below that do a pretty good job of showing how the method might be used in practice. It’s worth noting that the square brackets are only used in the initial description of the syntax, and not in the actual example code itself. The comma is only used when you need to separate out two parameters from each other.

Thanks so much, I wanted to understand well, and you helped. I am starting to take my JavaScript very serious these days. I often wondered about the use of these brackets in many programming language syntax examples. I think what you confirm is usually what I am seeing. Thanks

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.