r/javascript • u/bijusubhash • Dec 06 '09
r/javascript • u/wulfgar4president • Aug 10 '19
AskJS [AskJS] Why is React so popular considering it was made by Facebook?
I know this this question might tip off some people but I'm really interested to hear the opinions everyone have on that.
Facebook is not known for their "pro customer" service as matter of fact very often do we hear negative news about Facebook.
So why did the developers community embraced React to that magnitude?
Did you ever care React was made by Facebook when you started with it?
r/javascript • u/Fair-Process-7291 • Sep 23 '26
AskJS [AskJS] How do you stop sub-cent amounts like $500.004 from sneaking into state?
I am writing the rules engine for a small stock draft game in TypeScript and ran into two money bugs back to back. Curious how others handle this.
The first was a rounding bug. Splitting $1.14 across two picks offered $0.56 instead of $0.57. In floating point, 0.57 * 100 is 56.99999999999999, and Math.floor dropped the cent. The fix was doing the division in integer cents.
The second was worse. The check that decided whether a buy amount was allowed accepted $500.004. The reducer subtracts the amount straight from cash, so after that one buy the balance was no longer a whole number of cents. Every later calculation started from that balance, so the error did not stay in one place. It carried forward through the rest of the game.
My fix was a whole-cent check that tolerates float noise: reject the amount if Math.abs(amount * 100 - Math.round(amount * 100)) > 1e-6. Comparing against exactly zero does not work, because a perfectly valid amount like 0.57 fails that test for the same reason the rounding bug happened.
The takeaway for me: a rounding bug loses a cent once, but letting a bad amount into state corrupts every step after it.
So how do you handle this in plain JS? Do you convert to integer cents at the boundary and never let a decimal into state, use something like decimal.js or currency.js, or is a tolerance check like mine reasonable?
r/javascript • u/kiarash-irandoust • Oct 21 '18
Writing Redux in 15 lines of code
r/javascript • u/johnslegers • Dec 14 '17
Netflix functions without client-side React, and it's a good thing
r/javascript • u/alexmacarthur • Dec 29 '23
Let's Bring Back JavaScript's `with()` Statement
r/javascript • u/lost_tweaker • Jul 07 '12
Javascript: The Good Parts. Lol.
r/javascript • u/ccjsml • Aug 16 '24
AskJS [AskJS] The most simplest Javascript mutex implementation in the world.
I don't think you can find a version simpler than this.
export class Mutex {
private mutex = Promise.resolve();
lock(): Promise<() => void> {
return new Promise((resolve) => {
this.mutex = this.mutex.then(() => new Promise(resolve));
});
}
}To use it, do
mutex = new Mutex();
const unlock = await mutex.lock();
try {
// do something...
} finally {
unlock();
}r/javascript • u/JavaScriptWorks • Nov 29 '17
Why we have banned default exports in JavaScript and you should do the same
r/javascript • u/sqio • Aug 23 '13
How A Coding Method From 1970s Banking Software Could Save The Sanity Of Web Developers Everywhere
r/javascript • u/fagnerbrack • Jan 15 '24
Oxlint, a future replacement for ESLint?
r/javascript • u/GirkovArpa • Jun 30 '22
AskJS [AskJS] Anyone else use `claß` as a variable name since you can't use `class`?
const claß = "foo";
const element = <div class={claß}></div>;Surely I am not the first?
r/javascript • u/fagnerbrack • Jan 04 '20
Vanilla JavaScript and HTML - No frameworks. No libraries. No problem.
r/javascript • u/yo-inderella • Oct 02 '14
Full stack JS developer.....
About me: A girl (ok woman) wants to become a full stack js developer. Know basic Web development stuff (html css jquery..Twitter bootstrap) and a bit of JS
Can anyone provide me with a road map and some tools I should start picking up?
Thanks●
r/javascript • u/EpicEmeraldPlayz • Oct 12 '24
AskJS [AskJS] Do You Still Use jQuery in 2024, or Is Vanilla JavaScript the Way Forward?
Hey everyone!
I'm curious to hear your thoughts on the relevance of jQuery in 2024. With the evolution of vanilla JavaScript and the rise of modern frameworks like React, Vue, and others, is there still a place for jQuery in today's development landscape?
I've noticed some developers still using jQuery for smaller projects or quick prototypes, but I'm wondering if it's more efficient to stick with vanilla JS and its modern features. On the other hand, jQuery does offer simplicity and a vast plugin ecosystem that can speed up development in certain scenarios.
Questions:
When (if ever) do you prefer using jQuery over vanilla JavaScript in your projects?
Do you think jQuery still offers significant advantages, or have modern JS features rendered it obsolete?
Are there specific use cases where jQuery remains the better choice today?
Looking forward to hearing your opinions and experiences!
r/javascript • u/ngDev • Jul 02 '17
help Want to build an SPA without using the framework (Angular, React, Vue). Please help to compose a stack
Hey folks,
I want to build a Single Page Application without using heavy frameworks, like Angular, React, Vue.
First of all, I would like to mention, that I want to make an SPA, not single page website, so routing is required. I will need contexts (for filtering and passing data) and so far Page.js seems like the best option: http://smalljs.org/client-side-routing/page/
Second of all, I am not opinionated about templating, as long as it has If, Elif, Repeats and such. Even LoDash/Underscore 's _.template() seems to work as for me.
For control flow I am thinking of async.js.
The last, but not the least, the data binding and states. I have bad experience with Redux and Flux since both involve a lot of template code copy-pasting, and to be honest, are confusing. I have much better experience with two-way data binding and MobX. I am also very keen for RxJS and Bacon.js, so if you know solutions working tightly with them, please note that fact.
Finally, as for the build system. I have experience with both Gulp and Webpack. With Webpack, I managed to setup it to work with ESLint, which helped a lot during development. Gulp, however is easier for understanding and seems to be much more lightweight (but again, I might be opinionated because I used webpack for Angular 2 and React bundling).
As for the front-end framework, it's best to use Bootstrap if any needed. It's easy to make a grid system and other components from zero, but sometimes rapid prototyping is needed.
jQuery is neither a problem.
Here are the requirements:
E2E tests
IE9+ support, so ES6 has to be transformed with Babel into ES5
HTML partials, since I plan to inline SVGs a lot.
r/javascript • u/[deleted] • May 03 '24
Spent two years working on my own framework
r/javascript • u/WeakBack6749 • Dec 28 '25
Xmas.JS a new JavaScript/Typescript Runtime in RUST
Hello~ i am pretty new in Reddit~
This Xmas I started this project, the first reason is (my company need it and Deno/Node's memory usage blow our machine) modern JavaScript runtimes like Node.js, Deno, and Bun are excellent for web servers and applications, but they're overkill for scripting(or serverless)
If you find this project interesting, feel free to give me a star! ✨
r/javascript • u/SarahC • Apr 06 '14
"Balls deep in Javascript" - or "How I like linking lots of libraries."
r/javascript • u/gregbaugues • Mar 23 '23
We asked GPT-4 to write JavaScript that creates a map for a children's game
r/javascript • u/polaretto • Jan 25 '12