Not a problem with named arguments.
Too bad that they really screwed that up with ES6:
function foo({a = 1, b = 2} = {}) {...}
Dart's syntax is a lot easier to remember: foo({a: 1, b: 2}) {...}
Another very important detail: ES6's syntax is not declarative. You aren't restricted to "compile-time" constants and you can do all kinds of bogus stuff there. function foo({a = 1, b = 2, c} = {c: 3}) {
console.log(a, b, c);
}
foo(); // 1 2 3
foo({a: 'a'}); // a 2 undefined
foo({c: 'c'}); // 1 2 c
But wait! There is more! function foo({length = 2} = 'foobar') {
console.log(length);
}
foo(); // 6
foo({length: 0}); // 0
foo({x: 'x'}); // 2
Just look at that! Those short Hello World examples are already super confusing brain teasers.I really don't understand why they prioritized this kind of excessive flexibility over tooling. Now you can put entire programs into a function's signature. Why would anyone want that?