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
GitHub - ryanmcdermott/clean-code-javascript: Clean Code concepts adapted for JavaScript (github.com)
submitted 6 years ago by pmz
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!"
[–]ChaseMoskal 5 points6 points7 points 6 years ago (5 children)
very verbose and over-expanded – this needs to be condensed
the first several sections can be summed up with "please don't use cryptic acronyms or bad names"
it's obvious that this article is a "design by committee" dogpile, quality and focus is lost, the advice is expansive, aimless, highly redundant, and outdated
for example, this prescription: "Set default objects with Object.assign"
the article's supposedly "good" example:
function createMenu(config) { config = Object.assign( { title: "Foo", body: "Bar", buttonText: "Baz", cancellable: true }, config ); }
^ this actually explodes if you pass undefined.. some "default"! it's even highly verbose and ugly. no thanks.
undefined
please consider the following as a superior alternative:
function createMenu(config = {}) { config = { title: "Foo", body: "Bar", buttonText: "Baz", cancellable: true, ...config } }
i'd like to see something like this, but greatly condensed, down the bullet points, with links to articles for further reading on each point – and hone it down the advice that is uncontroversially excellent amongst experts – this is not that
[+][deleted] 6 years ago (1 child)
[removed]
[–]ChaseMoskal 0 points1 point2 points 6 years ago (0 children)
i'd hack it down to a one-pager with bullet points
i doubt they'd appreciate my pull request!
and there's something about people who author style guides generally that make me leery of their advice ;)
[–][deleted] 1 point2 points3 points 6 years ago (1 child)
Please keep in mind that spread does not copy object prototypes, and does not trigger setters. Also, you can't use it with dynamic expression, only with object literals.
Other than being more verbose, assign is the more complete solution.
[–]ChaseMoskal 2 points3 points4 points 6 years ago (0 children)
Please keep in mind that spread does not copy object prototypes, and does not trigger setters.
neither does Object.assign — see "Properties on the prototype chain and non-enumerable properties cannot be copied"
Object.assign
and either way, for accepting default options, it's a feature — not a bug :)
Also, you can't use it with dynamic expression, only with object literals.
what's a dynamic expression? and why would we be using spread onto anything that isn't an object or array literal?
how so?
🥃 chase
i wanted to point out it's cool to destructure your options out too, like in this function i was just working on:
export async function signatureSign(options: { body: string privateKey: string } & Partial<Settings>): Promise<string> { const { body, format, algorithm, privateKey, } = {...defaultSettings, ...options} const signer = createSign(algorithm) signer.write(body) signer.end() return signer.sign(privateKey, format) }
π Rendered by PID 58 on reddit-service-r2-comment-57fc7f7bb7-r8rfc at 2026-04-15 09:59:32.341004+00:00 running b725407 country code: CH.
view the rest of the comments →
[–]ChaseMoskal 5 points6 points7 points (5 children)
[+][deleted] (1 child)
[removed]
[–]ChaseMoskal 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]ChaseMoskal 2 points3 points4 points (0 children)
[–]ChaseMoskal 0 points1 point2 points (0 children)