r/javascript • u/Typical_Ad_6436 • Apr 11 '26
r/javascript • u/thepinkgiraffe123 • Sep 30 '21
I wrote a guide on how you can mint an NFT with JavaScript if anyone is curious!
r/javascript • u/jsloverr • Oct 09 '18
Writing Lighter, Faster JavaScript Functions
r/javascript • u/BennoDev19 • Aug 17 '25
Got tired of try-catch everywhere in TS, so I built a Result type that's just a tuple
github.comEver get tired of wrapping every JSON.parse() in try-catch? Been using Result libraries in TypeScript for a while, but got frustrated with the usual suspects.
What I wanted was something this simple:
const [ok, error, value] = t(() => JSON.parse('invalid'));
if (ok) {
console.log(value); // parsed data
} else {
console.log(error); // SyntaxError
}No more try-catch blocks, no more .value/.error boilerplate, just destructure and go.
The main pain points with existing libraries:
Hard to serialize - can't return from API endpoints without manual extraction (e.g. React Router loader)
Bloated - unnecessary class hierarchies and methods
Boilerplate - constant
.valueand.erroreverywhere
So I built tuple-result - a functional Result library that's literally just a 3-element array [boolean, E, T] with helper functions.
// Traditional Result pattern (still works!)
const result = Ok(42);
if (result.isOk()) {
console.log(result.value); // 42
} else {
console.log(result.error);
}
// "New" destructuring pattern (no more .value/.error boilerplate)
const [ok, error, value] = result;
if (ok) {
console.log(value); // 42
}
// Try wrapper for any function that might throw
const parseResult = t(() => JSON.parse(userInput));
const dbResult = t(() => db.user.findUnique({ where: { id } }));
// Functional helpers
const doubled = mapOk(result, x => x * 2);
const message = match(result, {
ok: (value) => `Success: ${value}`,
err: (error) => `Error: ${error}`
});Key differences from ts-results/neverthrow:
Just arrays - easy to serialize, works in Remix loaders, JSON responses
Functional approach - pure helper functions, no classes
Tree-shakable - import only what you need
Type-safe - full TypeScript literal types
Bundle size - core (Ok/Err only) ~150B, full library ~500B
The destructuring pattern was inspired by the ECMAScript Try Operator proposal - mixed that idea with my Result library needs.
Still experimental but definitely usable in production. Curious if others have hit the same serialization and boilerplate issues with Result libraries?
GitHub: github.com/builder-group/community/tree/develop/packages/tuple-result
r/javascript • u/whodadada • Sep 06 '15
Replace the word βmigrantβ with βfellow humanβ with a single click (bookmarklet)
r/javascript • u/pmz • Jan 12 '23
JavaScript localStorage: The complete guide
deadsimplechat.comr/javascript • u/kisancodes • May 28 '21
20 JavaScript Concepts you should know as a JavaScript Programmer!
r/javascript • u/jiri-urbandroid • Nov 01 '19
AskJS [AskJS] Does anyone still use plain Javascript (as opposed to Typescript) for any serious project? Why? What are the benefits (for you, anyway)?
r/javascript • u/fagnerbrack • Sep 20 '18
The Solo JavaScript Developer Challenging Google and Facebook
r/javascript • u/michaelkim_ • Apr 04 '23
Are TypeScript Enums Really Harmful?
r/javascript • u/legacye • May 03 '10
50 jQuery Snippets That Will Help You Become A Better JavaScript Developer
addyosmani.comr/javascript • u/[deleted] • Mar 28 '16
Babel 6 - useless by default - a lesson in how NOT to design software.
fourlightyears.blogspot.comr/javascript • u/__Disaster497 • Sep 18 '22
New Strings Method in ES6 JavaScript
r/javascript • u/dmitri14_gmail_com • Jan 13 '16
Please, Please Donβt Use βCSS in JSβ
r/javascript • u/curiousdannii • May 06 '17