In the section 3.8.2.2:
A parameter can be marked optional by following its name or binding pattern with a question mark (?) or by including an initializer. Initializers (including binding property or element initializers) are permitted only when the parameter list occurs in conjunction with a function body
However, following code:
function d1([a,b,c]?) {} // Error; binding pattern parameter can't be optional in an implementation parameter
function d1([a,b,c]?); // Allow
We should update the spec to indicate this difference because by only indicating that "A parameter can be marked optional by following its name or binding pattern with a question mark" is a bit misleading since it is only allow in non-implementation signature
鉂楋笍
This would be ridiculously useful! 馃槂
I have no idea how to submit a PR for this issue, but would be more than willing to put in the work if someone could give a little guidance!
Just realized it is possible to accomplish this! Just use the following:
function d1([a,b,c]=[]) {}
This issue could probably be closed, unless I'm missing something else. (Which I might be 馃槈 )
Most helpful comment
Just realized it is possible to accomplish this! Just use the following:
This issue could probably be closed, unless I'm missing something else. (Which I might be 馃槈 )