Replies: 2 comments 1 reply
-
Usually I think of optional in terms of (1). You don't have to pass it, and there's a default documented behavior if you don't. If we adopted (1), would there be a lot of counterintuitive results in the JS docs? (2) sounds all right as well though, depending on what "somewhat sane" means. From your example I think it would be fine to consider the argument in As for (3), I think, in your example of
Do you have interesting examples here too? |
Beta Was this translation helpful? Give feedback.
-
Well let's not do that then! That seems likely to commit us to different definitions for JS and Web/API already, right? and at that point maybe we should only consider https://github.com/orgs/mdn/discussions/452 for Web/API.
Sorry, I think I meant "optional" for |
Beta Was this translation helpful? Give feedback.
-
Quick question: what does it mean when we mark a parameter as
{{optional_inline}}
?"undefined"
)? In this sense, thesearchString
ofString.prototype.includes()
would be optional"undefined"
literally, but the algorithm can be described with or without the mention of optionalness? In this sense, thevalue
ofSet.prototype.has()
would be optionalundefined
is passed in, e.g. it gets converted to""
instead of"undefined"
? In this sense, theseparator
ofString.prototype.split()
is optionalundefined
is passed in?Hopefully no one says (1) or (4) so it's really a two-choice question. I'm also open to other interpretations. E.g. all interpretations above are based on behavior, but we may also look at what the spec marks as optional (in square brackets), or what
fn.length
gives. However, these give unintuitive results as well—for example, the spec thinks thecompareFn
ofArray.prototype.sort()
is not optional.A natural follow-up is: can an optional parameter be followed by a non-optional one, if we managed to rigorously define optionalness?
Beta Was this translation helpful? Give feedback.
All reactions