react
react
nextjs
What is the difference between Layout and Template in NextJS
Layout and template in NextJS look interchangeable but behave differently: a layout preserves state across navigation while a template remounts and rebuilds it on every visit. Code examples of both, plus guidance on when each one is the right choice.
javascript
How to deep equal in Javascript?
Deep equality in JavaScript is trickier than it looks: JSON.stringify fails when key order differs. Compare the real options: the deep-equal package, writing your own recursive check, lodash isEqual, and Node's built-in assert.deepStrictEqual.
Latest
BiomeJS - A 35x faster alternative to Prettier for formatting and linting
BiomeJS formats and lints JavaScript, TypeScript, JSX, and JSON up to 35x faster than Prettier, with almost 97% compatibility. How to install it, migrate your Prettier config to biome.json, and cut minutes off CI without changing how your code looks.
Event bubbling in Javascript and React
Event bubbling in JavaScript and React: how a click travels from the target element up the DOM tree, what benefits that gives you, and why React does not really bubble events but simulates them with its synthetic event system.
What is THIS word in Javascript
What 'this' means in JavaScript: why its value depends on how a function is called, how setTimeout callbacks break your assumptions, and how bind, call, and apply put you back in control, shown with simple Dog and Cat examples.
Event Loop in Javascript with examples
The JavaScript event loop explained with examples: how the single-threaded call stack executes tasks, where Web APIs take over timeouts and API calls, and how the event loop decides what runs next in the non-blocking I/O model.
Why we should use type unknown over any in Typescript?
TypeScript's unknown vs any: both bypass strict typing, but unknown forces you to narrow a value before using it, keeping the safety any throws away. Examples show how each behaves and why unknown is the safer default for untyped data.
How to send files from Javascript/React to a Ruby on Rails API Controller
Sending files from JavaScript or React to a Rails API: build a FormData object with the file and extra params, POST it with fetch, then read params[:file] in your controller. A minimal frontend plus backend walkthrough that works.
Introduction to the AbortController in JavaScript
JavaScript's AbortController lets you cancel fetch requests on demand: wiring an AbortSignal into fetch, calling abort, listening for the abort event, and handling cancelled requests without unhandled errors, with runnable examples.
Simplify complicated Typescript - KISS
Simplifying complicated TypeScript with the KISS principle: refactoring examples show when explicit types improve a simple function and when clever type gymnastics make code harder to review, test, and maintain.
Understanding Record type in Typescript
The Record utility type in TypeScript builds object types with fixed keys and value types. A worked example shows Record<Keys, Type> with union keys: restricting IDs to chosen literals and mixing User and AdminUser values, so the compiler flags missing or extra entries.
What is prototype in Javascript?
JavaScript prototypes explained through a working example: turning a standalone myCustomForEach helper into an Array.prototype method you can call directly on any array. See how prototypes share properties and methods between instances of the same object type.
Understanding the Singleton Pattern in Javascript
The Singleton pattern in JavaScript ensures one shared instance with a global access point. A practical implementation using an object literal and Object.freeze, a shared bucket example, and where a singleton fits: configuration, logging, or a central data store.
Understanding TypeScript Function Generators
TypeScript function generators can pause and resume execution, returning values one at a time instead of all at once. What generators are, how yield works in a simple example, and a practical number sum generator that shows where they beat regular functions.
How to simplify TypeScript types and reduce documentation overhead
TypeScript types with many optional fields need comments to explain what goes together. Discriminated unions fix that: split a Task type into per-status variants so invalid combinations fail to compile and the type documents itself. Before and after code included.
Understanding generic types in Typescript
Generic types in TypeScript let one function, class, or interface work safely with many data types. What generics are, how a type parameter beats hardcoding a concrete entity type in a validation helper, and honest pros and cons before you use them everywhere.
Enums with Typescript - why it's bad? Possible solutions
TypeScript enums generate extra JavaScript at compile time and numeric enums are not even type-safe. Why enums can hurt bundle size and correctness, and two safer alternatives: assigning explicit string values or replacing enums with plain objects.
Ruby in browser via WebAssembly
Ruby 3.2 runs in the browser through WebAssembly: embed Ruby in a script tag with ruby-wasm-wasi or drive the Ruby VM from JavaScript and mix it with HTML. Working examples plus honest limits: no threading or networking, and no extra gems without a custom wasm image.
Map vs WeakMap in practice
Map vs WeakMap in JavaScript comes down to keys and memory: WeakMap only accepts object keys and lets garbage collection reclaim unused entries, while Map holds onto everything. Differences, similarities, and practical guidance on when each one is the right choice.