How to deep equal in Javascript? 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.

Jul 1, 2024

Event bubbling in Javascript and React

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 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

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.

Introduction to the AbortController in JavaScript

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

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

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?

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

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

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.

Understanding generic types in Typescript

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.

Ruby in browser via WebAssembly

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 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.