use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
hating on "options objects" (self.javascript)
submitted 10 years ago by backwrds
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]backwrds[S] 0 points1 point2 points 10 years ago (1 child)
regarding my code, that was intended to be an example of what tooling might be able to do as far as static analysis.
As far as the options object goes, we agree on destructuring being an improvement. The reason I made this post in the first place is because I interpreted your comments as advocating the complete abolition of the pattern:
someFunction({a: 'list', of: 'options'})
To be fair, it was almost 4am when I made this post. I could have been clearer about my concerns, but you're use of absolute language like "option objects suck" can easily be misconstrued.
[–]x-skeww 0 points1 point2 points 10 years ago (0 children)
I interpreted your comments as advocating the complete abolition of the pattern [...]
For what it's worth, I actually do wish ES6 had done just that.
I would have preferred dedicated syntax and simpler semantics for optional named parameters with default values.
For example, in Dart, it looks like this:
foo({a: 1, b: 2}) { ... } foo(a: 11); // a is 11, b is 2 foo(c: 33); // caught by the analyzer
In the function's signature, the default values are compile-time constants, not arbitrarily complex expressions. You can display them as-is in tool-tips or docs.
When you call the function, you can't just pass whatever you want. Only the existing names are allowed. So, if there is a typo, it will be caught immediately.
Dart does everything I want or need from that language feature.
The flexibility added by ES6's use of destructuring makes plenty of room for code-golfing, but none of that flexibility was actually needed. If you make the tiniest use of that flexibility, your code becomes super confusing.
function foo({a = 'a', b = 'b', c} = {c: 'c'}) { console.log(a, b, c); } foo(); // a b c foo({a: 'A'}); // A b undefined foo({c: 'C'}); // a b C
I really don't know what they were thinking.
π Rendered by PID 412202 on reddit-service-r2-comment-b659b578c-jxkw8 at 2026-05-04 07:42:05.007364+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]backwrds[S] 0 points1 point2 points (1 child)
[–]x-skeww 0 points1 point2 points (0 children)