+ 4
Need help to understand the arguments syntax in functions at MDN web docs
what's with the weird array like notation in MDN for the arguments . syntax for Array.prototype.fill() is arr.fill(value[, start [, end]]), but I ll be using it like this , arr.fill( value, start, end) so what's the meaning of that nested array notation in arguments that I see everywhere, in MDN documentations https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill I understand all the functions but why that array notation in functions arguments
5 Antworten
+ 2
They are nested if an optional argument is only valid if it comes after another optional argument.
In the example you provided, the start value is optional, and the end value is optional too. However, the end argument can only be used if the start argument has been used too, that's why the optional end argument is inside the optional start argument brackets.
+ 5
Thank you splitty Dev, u know I was badly scratching my head because of that, 😅.
+ 3
ok, but why nested then
+ 2
Arguments in square brackets mean that they're optional.
+ 2
No problem, I understand your confusion :P