#JavaScript
17 posts tagged with this topic. ← All tags
-
Long polling: the technique that works when WebSockets don't.
Long polling simulates real-time updates using regular HTTP requests held open until data is available. It's a reliable fallback and sometimes the right primary approach.
-
Server-sent events: one-way streaming without WebSocket complexity.
Server-sent events push data from server to client over a persistent HTTP connection. For many real-time use cases they're simpler and more appropriate than WebSockets.
-
WebRTC: peer-to-peer connections from the browser.
WebRTC enables direct browser-to-browser communication for video, audio, and data — without routing media through a server. Here's how the connection setup actually works.
-
WebAssembly: running near-native code in the browser.
How WebAssembly works, how to compile Rust and C to Wasm, and when it makes sense to reach for it.
-
Service workers: offline capability without a native app.
How service workers intercept network requests to enable offline functionality, background sync, and push notifications.
-
Web Workers: offloading computation without blocking the main thread.
How Web Workers move CPU-intensive tasks off the main thread, with examples for parsing, image processing, and communication patterns.
-
require() vs import: they look the same and work completely differently.
CommonJS require() and ES module import are not interchangeable. Understanding the difference explains module compatibility issues and bundler behavior.
-
Immutability in JavaScript without a library.
You don't need Immutable.js or Immer for most immutability needs. Native JavaScript gives you the tools.
-
Spread syntax does two different things depending on where you put it.
The ... syntax is used in two fundamentally different ways in JavaScript. Knowing the difference makes destructuring and function signatures clearer.
-
Default exports break refactoring. Named exports don't.
Default exports let consumers name imports anything they want. This creates invisible coupling that makes renaming and codebase searches unreliable.
-
Map and Set exist for a reason. Here's when arrays are the wrong choice.
Arrays are the default collection in JavaScript, but Map and Set are more correct for specific use cases. Here's when and why.
-
Why setTimeout(fn, 0) doesn't run immediately.
setTimeout with a zero delay is not immediate. Understanding why requires understanding the event loop.
-
Closures are not magic. One example that makes them click forever.
Closures are the mechanism behind half of JavaScript's patterns. One concrete example explains them permanently.
-
Optional chaining saved me from 40 null checks. Here's how.
Optional chaining (?.) is not just shorter code. It changes how you navigate uncertain data structures.
-
Destructuring looks simple. It has one trap that breaks real code.
Destructuring is convenient, but renaming, defaults, and nested patterns have edge cases that catch everyone at some point.
-
You're using async/await without knowing what it hides.
async/await is syntactic sugar over Promises. Understanding what it compiles to explains every confusing behavior.
-
Stop writing for loops. These 7 array methods do it better.
For loops are verbose, error-prone, and harder to read. Modern array methods express intent and reduce bugs.