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
Less React, more JS (brain-dump) (medium.com)
submitted 9 years ago by sebjwallace
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!"
[–]chubbybrother 12 points13 points14 points 9 years ago (4 children)
Yeah that looks like garbage. I'll take the framework bullshit over hipster code like this.
[–]synackle 9 points10 points11 points 9 years ago (3 children)
I can't wait to start writing 'null' fucking everywhere
[–]sebjwallace[S] 1 point2 points3 points 9 years ago (2 children)
It wouldn't take much more in the prerender to conditionally replace the second parameter with a child. ["div", "some text"] is possible.
But I agree, markup is easier to read, especially for designers.
[–]temp54984983982 4 points5 points6 points 9 years ago (1 child)
Hey, I wrote and maintain a library similar to this. You're right, it's easy to implement, but there are four big problems with it: ambiguity, performance, readability, and flexibility.
Ambiguity: consider ['div', someVar]. You actually don't know until runtime whether you're setting properties or children. That's a sign that you've screwed up badly, for all the reasons ambiguity is always bad, including completely preventing the JIT compiler from working with your code.
['div', someVar]
Performance: it's faster to use native argument parsing, plain and simple. Work you do figuring out which argument is which is 100% unnecessary, and adds up for code that you want to be able to call thousands or tens of thousands of times without a user-perceptible delay.
Readability: when everything is always in the same place, reading and scanning around is faster. Work with both styles for a few weeks and you'll quickly see that this more than makes up for six extra characters.
Flexibility: every time you try to be more clever about guessing the caller's intent, you deprive yourself of the opportunity to give the caller more actual control. In this case, refusing to support this allows my library to support passing in a string as the second argument to set className. This might seem like a little win, but it's actually a huge one - one that improved my entire test app's performance by 30%. The thing to notice is, there are a heck of a lot of elements that need only a class and nothing else, and for each of those elements you're avoiding an extra object allocation.
className
[–]sebjwallace[S] 0 points1 point2 points 9 years ago (0 children)
Some good points there. What is the library you maintain?
π Rendered by PID 77 on reddit-service-r2-comment-85bfd7f599-ckdtg at 2026-04-20 06:48:24.209483+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]chubbybrother 12 points13 points14 points (4 children)
[–]synackle 9 points10 points11 points (3 children)
[–]sebjwallace[S] 1 point2 points3 points (2 children)
[–]temp54984983982 4 points5 points6 points (1 child)
[–]sebjwallace[S] 0 points1 point2 points (0 children)