3 ms·
Why write "base=5"? That makes it a variable, not a python-style named argument.
by tgv 5y ago
Why write "base=5"? That makes it a variable, not a python-style named argument.
- jeroenhd 5y agoI suppose it works as a poor man's named argument. You still need to follow the argument order, but the code might be slightly more readable at the expense of creating random variables all over your code. The expression `a = 5` evaluates to 5 after all, which allows things like `a = b = c = d = 0` or the listed `let a = b = 5` which can cause confusion.
- wonderbore 5y ago> I suppose it works as a poor man's named argument. Sure, if by “poor man” you refer to the guy who has to debug that “code”. Name a variable with an existing or unwritable `window` property and enjoy. Don’t do this stuff, use a linter and a decent editor that can do this automatically.
- conaclos 5y agoMoreover in a ESM, this could lead to an error whether base is not defined.
- cranium 5y agoMy bad, too much Python lately. I wanted to be more explicit about this argument and briefly tested the syntax in a Node console. It works, but... I didn't catch the atrocious side effect. Thanks for pointing the footgun !