Description
We have foo([x = 42])
and foo({x: 42})
as the ways to specify default values for parameters.
That means that changing your function from a positional parameter to a named parameter is not just changing the []
to {}
, you also have to change =
to :
- but it still means exactly the same thing (default value). This breaks the rule about similar things having similar syntax.
Even without changing from one type of parameter to another, I still regularly write =
for named parameters. There is simply nothing to remind me that it's not =
.
It might be cute that it 1) looks like a map or 2) looks like how the function is called, but the former is only true in trivial cases and the latter isn't helping anyway - it's not like positional parameter default values looks like arguments in a function call.