Honestly I’m a little surprised you haven’t seen this pattern. The only times it wouldn’t be used are when people rename variables, which is frankly a practice I abhor.
Honestly I’m a little surprised you haven’t seen this pattern. The only times it wouldn’t be used are when people rename variables, which is frankly a practice I abhor.
I'm not trying to be snarky, but e.g. I haven't seen it in Go, F# and Rust, some languages where I have at least seen _some_ code. I also don't remember a similar pattern in Java, C# and C nor PHP or Dart, but I will readily admit that it's I haven't coded in any of these in the last two years, so I might be a bit out of touch and I'm not super proficient in all those languages
We are talking named/keyword/etc.
Personally I find positional arguments to be an anti-pattern in all but a very specific set of circumstances.
In JS, when creating an object, instead of writing {name: name}, where "name" is both the key in the map as well as the variable you want it to assign to, you can do {name}, whereas e.g. in Go you would do map[string]any{"name": name}.
Edit: Or, for completeness' sake, it's the same with structs in Go, where you would instantiate a struct like this: Person{name: name}.
I've probably used it more for pattern matching (`let Foo { bar, baz } = ...`), but haven't measured the number of instances of that idiom.