I’m reading a blog article about how to use the forEach() method in javascript, and what it gives to explain which parameters this method takes is this:
array.forEach(callback(currentVal [, index [, array]])[, thisVal])
what’s the correct way to read these “structures”:
currentVal [, index [, array]]
and [, thisVal]
Why does it look like currentVal
, index
, and array
are in a nested structure?
Why not just use ,
instead of [,
. I’m sure there’s a good reason, but I just don’t know what it is. I see this format a bunch in documentation all the time, but have never picked up why it’s written like this.