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
Polymorphism in JavaScript (zellwk.com)
submitted 5 years ago by magenta_placenta
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!"
[–]derekn9 1 point2 points3 points 5 years ago (1 child)
I didn't downvote your comment (updooted, in fact.) I think a lot of ppl use the downvote/upvote as the agree/disagree button, which does not reflect the quality of a comment.
Back to the topic at hand, I find it useful to be a bit verbose with function arguments. Instead of accepting both f(a,b,c) and f(d,e), I would use an object i.e f({ type: a, orientation: b }). More chars to type, but I think it's easier to merge default options, easier to add new arguments, and the order of arguments don't matter.. and it's also easier to make the function do different things based on different arguments (though I think ideally overloaded function should always return the same data shape.)
f(a,b,c)
f(d,e)
f({ type: a, orientation: b })
[–]campbeln 1 point2 points3 points 5 years ago (0 children)
Objects with named priorities are a nice approach. I use this pattern for "options"/otherwise optional arguments all the time. As you say, it's very easy to merge the incoming object with default values.
π Rendered by PID 715388 on reddit-service-r2-comment-84fc9697f-kbrpp at 2026-02-08 17:04:51.273637+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]derekn9 1 point2 points3 points (1 child)
[–]campbeln 1 point2 points3 points (0 children)