What Does This Documentation Syntax Mean At Mdn For A Javascript Function?
I'm learning JavaScript through 'Eloquent JavaScript' manual and now I'm doing exercises from chapter 5 'High-Order Functions'. One of the functions this chapter introduces you is
Solution 1:
It's usually a convention for API documentations to use []
to denote optional parameters. However, the []
is not part of the syntax on usage. It's just documentation convention.
Solution 2:
As already explained in other answers, the parameters inside of the "[]" are optional. Regarding the question as to why the "other parameters" (i.e. previousValue etc.) are not there, those are parameters to callback
and not to reduce
. So callback
will receive those arguments on each run of reduce
.
Post a Comment for "What Does This Documentation Syntax Mean At Mdn For A Javascript Function?"