Articles by Olorunfemi Akinlua
JavaScript array slice: slicing, negative indexes, slice vs splice, TypedArray
How Array.prototype.slice works in JavaScript: javascript array slice, js array slice, javascript array slicing with slice(start, end), exclusive end, negative indices, shallow copy, slice vs splice, TypedArray subarray …
JavaScript array pop: remove last element, return value, empty array, slice
How pop works in JavaScript: javascript pop, javascript array pop, js array pop with Array.prototype.pop, return value, empty array undefined, pop in javascript, generic array-like objects, and immutable alternatives …
Flatten array JavaScript: flat, flat(Infinity), flatMap, concat, reduce
How to flatten an array in JavaScript: flatten array javascript, js flatten array, javascript flatten array with flat(), depth and Infinity, flatMap vs map+flat(1), recursive concat/reduce for legacy engines, non-array …
JavaScript error: IPython is not defined (Jupyter & matplotlib fix)
Fix missing IPython in the notebook browser context: secure URL, matplotlib backend (%matplotlib inline vs widget/ipympl), kernel restart, VS Code Jupyter extension, and Permissions-Policy. Includes one runnable Node …
JavaScript array fill: Array.prototype.fill, start/end, typed arrays, Array.from
How Array.prototype.fill works in JavaScript: javascript array fill, fill array js, array.fill with value and optional start/end, exclusive end, negative indices, object reference gotcha, new Array(n).fill, typed arrays, …
JavaScript DOM selectors: querySelector, getElementById, and more
JavaScript DOM selectors: querySelector, querySelectorAll, getElementById, getElementsByClassName, getElementsByTagName, live HTMLCollection vs static NodeList. Snippets use `{run=false}`—inject the sample HTML in a …
JavaScript dictionary: objects, Map, and dict patterns
JavaScript dictionary guide: plain objects vs Map for key-value data (js dict / dict in javascript). CRUD, iteration, Object.create(null), non-string keys, and Object.fromEntries. Short notes after snippets describe …
JavaScript destructuring: arrays, objects, defaults, and function params
javascript destructuring and destructuring assignment: array destructuring javascript (order, skip, rest, defaults), object destructuring javascript (rename, nested, rest), function parameters with = {}, for-of patterns, …
JavaScript deep copy: structuredClone, JSON, and when each one breaks
javascript deep copy, deep copy javascript, js deep copy, and deep copy object javascript: shallow spread and Object.assign, structuredClone for nested cloneable data, JSON.parse(JSON.stringify) limits, lodash cloneDeep, …
JavaScript CSV to array: read & parse CSV into arrays (browser & Node.js)
javascript csv to array and read csv file into array: 1D lists, 2D row arrays, and header-keyed objects; javascript parse csv with split for simple data, BOM and quotes, fetch and FileReader, Node readline and …
JavaScript arguments object vs parameters: strict mode, rest, and args
How the javascript arguments object works: args javascript, javascript arguments object vs parameters, sloppy-mode aliasing, strict mode, default parameters, variadic sum, Array.from(arguments), rest parameters vs spread …
JavaScript Nested Functions: Inner Function and Closure Examples
JavaScript nested functions: inner functions, scope, closures, private helpers, and when nesting stays readable.
Append to a JavaScript array: push, spread, concat (and prepend with unshift)
How to append to arrays in JavaScript: javascript append to array, js append to array with push and return value, push(...arr), spread literals, concat for new arrays, nested push gotcha, unshift prepend, and push.apply …
JavaScript event bubbling: DOM propagation and delegation
Event bubbling: inner-to-outer delivery, delegation on a parent, stopPropagation vs preventDefault, and capture phase contrast. Snippets use `{run=false}`—run in DevTools or with jsdom/happy-dom where markup exists.
JavaScript addEventListener (DOM events, options, and examples)
JavaScript addEventListener on document, window, and elements: click, capture vs bubble, removeEventListener, once, passive, AbortSignal, delegation, and Node EventEmitter. DOM snippets use `{run=false}` (install jsdom …
JavaScript forEach vs for...in (arrays and objects)
Compare Array.prototype.forEach with for...in on objects and arrays, when for...of wins, and how to avoid enumerable-key bugs. Runnable Node snippets with short output notes.
Date/time out of range in JavaScript (and the PostgreSQL pq error)
Compare Date values in JavaScript to detect out-of-range times, and fix PostgreSQL pq: date/time field out of range from bad string formats.
JavaScript add to array: push, unshift, splice, concat, spread, length
How to add to arrays in JavaScript: javascript add to array, js add to array with push, unshift, splice, toSpliced, concat, spread, length holes, javascript add array to array, mutating vs new array, and links to append …
Add days to a date in JavaScript (UTC, local, DST caveats)
How to javascript add days to date and js date add days: getUTCDate/setUTCDate for UTC calendar days, getDate/setDate for local wall calendar, immutable copy pattern, getTime + 86400000 ms vs DST, negative days, and Intl …
insertBefore in JavaScript (DOM, null, nextSibling)
insertBefore javascript and js insert before: parent.insertBefore(newNode, referenceNode), referenceNode null for end append, firstChild text nodes, insert after via nextSibling, TypeError if second arg omitted. Examples …
Call a function every second in JavaScript (setInterval, cleanup)
JavaScript call function every second and every 5 seconds with setInterval and clearInterval, recursive setTimeout when work overlaps, setTimeout delays, async delay helper, timer cleanup, and Node/browser throttling …
JavaScript array range (Array.from, start/stop/step, loop)
Numeric ranges with Array.from, start/stop/step helpers, loops, and keys(). Snippets include short expected-output notes from Node runs.
How to copy an array in JavaScript (shallow vs deep)
JavaScript copy array: shallow copies with spread, slice, Array.from, concat, map, and filter; deep copies with structuredClone; JSON limitations; sparse-array caveats. Snippets include short expected-output notes from …
HashSet in JavaScript (`Set`, uniqueness, Map vs dedupe)
Hashset JavaScript and js hashset: use Set for unique values like a HashSet, add/has/delete, SameValueZero and NaN, object identity, dedupe arrays with spread, Map when you need keys. Section intros explain each pattern; …
Convert string to array JavaScript (split, Array.from, Unicode)
How to convert string to array in JavaScript: string to array javascript, javascript string to array, js string to array, convert string to array javascript with split, Array.from, spread, javascript string to char …
JavaScript copy to clipboard (navigator.clipboard.writeText, secure context)
Copy text to the clipboard with navigator.clipboard.writeText, secure contexts, NotAllowedError, readText, and why execCommand is legacy. Node uses a stub clipboard in examples so snippets run; browsers need HTTPS and …
JavaScript clone object (shallow spread, structuredClone, JSON)
Clone objects in JavaScript: shallow spread and Object.assign, for...in, Object.create + descriptors, JSON limits, structuredClone and DataCloneError, and circular refs. Runnable Node snippets with short output notes; …
JavaScript classes tutorial (constructor, methods, static, extends)
JavaScript classes: constructor, instance methods, getters, static methods, extends and super, public fields, and private # fields. Runnable Node snippets with short expected-output notes; links to ranges and cloning …
JavaScript check if undefined (typeof, ===, void 0, nullish)
Check undefined in JavaScript: typeof for undeclared names, === undefined for declared bindings, falsy vs undefined, == null, void 0, and nullish coalescing (??) for defaults. Runnable Node snippets with short output …
JavaScript check if string is number (Number.isFinite, isNaN, parseInt)
Validate numeric strings in JavaScript: whole-token checks with trim + Number.isFinite, global isNaN pitfalls, parseInt prefix behavior, integers, strict regex decimals, and digits-in-text vs fully numeric. Runnable Node …
