2 ms·
The first solution can be done in JavaScript and it is done sometimes, but other times it may be undesirable, especially for refactoring. The second solution wa
by jchw 6y ago
The first solution can be done in JavaScript and it is done sometimes, but other times it may be undesirable, especially for refactoring. The second solution was done; ECMAScript (since the 2015 edition) supports explicit default arguments.
When you add TypeScript into the mix, it can help a lot as it is often able to detect under- and over-application as type errors (though not always, due to intentional looseness in the language; TypeScript is not fully sound.)