javascript

LocalStorage, SessionStorage, and IndexedDB

Web storage APIs persist data in the browser. I use localStorage for permanent client-side storage across sessions. The sessionStorage API stores data for single sessions that clears when tabs close. Both provide simple key-value storage with 5-10MB l

ES6+ features: destructuring, spread operator, and template literals

ES6 destructuring extracts values from arrays and objects with concise syntax. I use const [a, b] = array for array destructuring and const {name, age} = obj for objects. The spread operator ... expands iterables in arrays, objects, and function argum

TypeScript fundamentals for type-safe front-end code

TypeScript adds static typing to JavaScript for better code quality. I define types with interfaces and type aliases for clear contracts. Type annotations like : string, : number catch errors at compile time. Generics enable reusable, type-safe compon

Stimulus controller for dynamic form interactions

Stimulus brings just enough JavaScript to make static Rails views interactive while staying close to the HTML. Controllers connect to DOM elements via data-controller, and actions bind to events with data-action. I use Stimulus for client-side validat

WebSockets for real-time bidirectional communication

WebSockets enable real-time, full-duplex communication between client and server. I create WebSocket connections with new WebSocket(url) for persistent connections. The protocol uses ws:// or wss:// (secure) URLs. Events like onopen, onmessage, onerro

JavaScript classes and prototype-based inheritance

JavaScript classes provide syntactic sugar over prototype-based inheritance using class keyword. I define constructors with constructor() method for initialization. Using extends creates subclasses that inherit from parent classes. The super keyword c

Stimulus controller for drag-and-drop file uploads

Modern file uploads should support drag-and-drop in addition to traditional file inputs. I use Stimulus to handle dragover, drop, and paste events, showing upload previews and progress. The controller prevents default browser behavior for drag events

Array methods: map, filter, reduce, and functional programming

Array methods enable functional programming patterns in JavaScript. The .map() method transforms each element and returns new array. I use .filter() to create arrays with elements meeting criteria. The .reduce() method accumulates values into single r

wasm-bindgen for Rust to JavaScript interop in WebAssembly

Wasm-bindgen generates JavaScript bindings for Rust code compiled to WebAssembly. Annotate functions with #[wasm_bindgen], and the tool generates JS glue code. I use it to write performance-critical browser code in Rust: parsers, crypto, data processi

Stimulus controller for dependent select dropdowns

Dependent dropdowns are a classic UX pattern where one select populates based on another's value. With Stimulus, I handle this entirely client-side after the initial page load by storing options as data attributes or fetching them via AJAX. When the p

React hooks - useState, useEffect, and custom hooks

React Hooks enable state and lifecycle features in function components. I use useState to add stateful values that persist between renders. The useEffect hook handles side effects like data fetching, subscriptions, and DOM manipulation. Dependencies a

JavaScript closures and lexical scope fundamentals

Closures allow functions to access variables from outer scopes even after outer function returns. I create closures when inner functions reference outer function variables. Lexical scope means functions look up variables where they're defined, not whe