|
|
|
|
|
by chmod775
2038 days ago
|
|
You can get a much more powerful alternative for "free" if you support de-structuring assignments (in arguments). JavaScript Example: function test({a,b,c}) {
console.log(c,b,a)
};
test({
a: 1,
b: 2,
c: 3
});
If you have this there's really no need for named arguments anymore. If you add features to your de-structuring, your "named arguments" will have them too (things missing for JS specifically: optional objects, TS support to specify types for the destructured objects inline instead of repeating the entire thing). |
|
With your object properties approach, you always have to use the variable "names".