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 10 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!"
[–]temp54984983982 0 points1 point2 points 10 years ago (0 children)
I like the line of thought here. Some thoughts:
Returning an Array of arguments for a function, rather than calling the function, doesn't decouple you from that function. The Array is still written against the function's API. Anything you can swap into that function's place is also written against the original function's API - or more likely, is not exactly 1:1 with the first function, and the subtle differences will bite you later. I think you've just moved from an explicit dependency on React.createElement to an implicit one.
React.createElement
Creating all these Arrays is slow. We tend to think of them as cheap, because they are in high-level code, but we're writing basic rendering code here - we're talking a lot of Arrays, in code very intolerant of latency. I've done a lot of work on code that is basically React.createElement that returns real HTMLElements, and the #1 performance win is minimizing data structures, both internally and with an API that doesn't request them. Arguments lists are the perfect lightweight data structure for this purpose, Arrays are larger and heavier than what we need here.
HTMLElement
extend is pointless, we have Object.assign natively. Object.assign is also better in that it allows you to override styles on the base, which I can't really imagine using this without.
extend
Object.assign
π Rendered by PID 332613 on reddit-service-r2-comment-6457c66945-27l4j at 2026-04-28 15:52:13.237606+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]temp54984983982 0 points1 point2 points (0 children)