MDN is my primary Javascript resource.
I often see a notation like ( currentValue[, index[, array]])
as in:
l
It is an invalid JS syntax, and it would throw an error.
However, it is used to denote optional arguments as a pseudo-code.
The parts in the square brackets are considered optional (and in the real code the brackets should be omitted), so, you might call this function like:
let new_array = arr.map(function callback(currentValue) {
// return element for new_array
})
//or
let new_array = arr.map(function callback(currentValue) {
// return element for new_array
}, thisArg)
//or
let new_array = arr.map(function callback(currentValue, index) {
// return element for new_array
})
//or
let new_array = arr.map(function callback(currentValue, index) {
// return element for new_array
}, thisArg)
//or
let new_array = arr.map(function callback(currentValue, index, array) {
// return element for new_array
})
//or
let new_array = arr.map(function callback(currentValue, index, array) {
// return element for new_array
}, thisArg)
and each of them is valid.
That means the callback requires a currentValue as the first argument, and index and array are optional arguments.
The square brackets mean that the enclosed parameter is optional.
Refer MDN syntax section for more info.