Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
The JavaScript Event Loop in Depth: Tasks, Microtasks and Rendering Order
We work through output-order puzzles to see the task and microtask queues, where promises and queueMicrotask fit, when requestAnimationFrame runs in the rendering step, and why long tasks freeze the page.
JavaScript OOP Patterns: Inheritance or Composition? Factory Functions and Mixins
We talk about the cost of inheritance, combining behavior with composition, factory functions and mixins, choosing between closures and #private, the SOLID principles that fit JavaScript, and when a class is worth writing.
JavaScript Object Protection and Immutability: Property Descriptors, seal and freeze
We look at property descriptors, the sneaky defaults of Object.defineProperty, the difference between preventExtensions, seal and freeze, shallow versus deep freezing, and patterns for updating objects without mutating them.
The JavaScript Prototype Chain: How Objects Inherit from Each Other
We untangle the [[Prototype]] link, property lookup along the chain, __proto__ versus Object.getPrototypeOf, constructor functions, Object.create and the prototype machinery underneath class, step by step in the console.
TypeScript Declaration Files: .d.ts, @types, declare and Global Augmentation
We look at what .d.ts files are, @types and DefinitelyTyped, writing your own declarations with declare module, ambient declarations, global augmentation with declare global, and generating .d.ts with declaration: true.
TypeScript Enums, Namespaces and Parameter Properties: Syntax That Isn't Erasable
We examine numeric and string enums, const enum, namespaces and parameter properties through their compiled output, and see why they aren't erasable, erasableSyntaxOnly, and the as const alternative.
Error Handling in TypeScript: unknown in catch, Narrowing Errors and the Result Pattern
We look at why the catch variable is unknown, narrowing with instanceof Error, custom error classes, Promise pitfalls, and modeling errors with Result and discriminated unions.
Modules in TypeScript: import type, verbatimModuleSyntax and File Extensions
We look at modules versus scripts in TypeScript, import type and export type, why verbatimModuleSyntax matters, .ts extensions in imports, and bundler versus nodenext resolution.
Asynchronous Code in TypeScript: Typing Promise, async and fetch Responses
We look at Promise<T> and async return types, why a fetch response is any, runtime validation with unknown and hand-written type guards, and the types of Promise.all and allSettled.
TypeScript Type Guards: Type Predicates and Assertion Functions
We write type predicates with x is T and assertion functions with asserts, and look at TypeScript 5.5's inferred type predicates and narrowing arrays with filter, pitfalls included.
TypeScript Utility Types 2: Exclude, Extract, NonNullable, ReturnType and More
We filter unions with Exclude, Extract and NonNullable, and derive types from functions and classes with ReturnType, Parameters, Awaited, InstanceType and ConstructorParameters.
TypeScript Utility Types 1: Partial, Required, Readonly, Pick, Omit and Record
We use Partial, Required, Readonly, Pick, Omit and Record with realistic examples, combine them in a form model and look at silent pitfalls such as a typo inside Omit.