Articles by Olorunfemi Akinlua
JavaScript Print Object: console.log and JSON.stringify Examples
Learn how to print objects in JavaScript using console.log(), JSON.stringify(), console.table(), Object.keys(), Object.values(), and object entries.
JavaScript slice(): Array and String Examples
Learn JavaScript slice() for arrays and strings, including start/end indexes, negative indexes, shallow copy behavior, and slice vs splice.
JavaScript Send Tab Key and Detect Tab Key Press
Learn how to detect the Tab key in JavaScript, understand keyCode 9, handle KeyboardEvent.key, and why browsers restrict simulated Tab navigation.
JavaScript Sort by Date: Ascending and Descending Examples
Learn how to sort dates in JavaScript using Array.sort(), Date objects, timestamps, ascending and descending order, and safe ISO date strings.
JavaScript replaceWith() Method Explained
Learn JavaScript replaceWith() with examples for replacing an element with a node, text, or multiple nodes, plus replaceWith vs replaceChild.
JavaScript Set Remove Element with delete()
Learn how to remove an element from a Set in JavaScript using Set.delete(), check the boolean return value, clear all values, and remove object references.
JavaScript timestamp: get, generate, and convert epoch time
javascript timestamp, js timestamp, javascript get timestamp, timestamp javascript, javascript generate timestamp: Date.now, getTime, Unix seconds, ISO strings, performance.now, with Node-verified output.
JavaScript loop through object: forEach, keys, entries (javascript foreach object)
javascript foreach object, javascript loop through object, loop through object javascript, js foreach object, js loop through object, js object foreach, foreach object js, javascript iterate object, object foreach …
JavaScript get current date and time: new Date, UTC fields, and strings
javascript get current date, js get date, get current date javascript, javascript current date, javascript get date, js get current date, get date javascript, current date javascript, javascript datetime now: new Date(), …
JavaScript Keyboard Events: keydown, keyup, and keypress
JavaScript keyboard events: keydown, keyup, deprecated keypress, KeyboardEvent.key and code, repeat, preventDefault. happy-dom–style notes describe simulated output; DOM excerpts use `{run=false}` where appropriate.
Global variable in JavaScript: globalThis, var, strict mode, and multiple files
javascript global variable across files, javascript global variable, js global variable, global variable javascript, global variable in javascript, global var in javascript, var global js, var global javascript, global …
getBoundingClientRect in JavaScript: DOMRect, viewport coordinates, and performance
getboundingclientrect, get bounding client rect, getboundingclientrect javascript, javascript getboundingclientrect, js getboundingclientrect, boundingclientrect, getboundingclientrect performance, mdn …
JavaScript iterator and generator: iterators, js iterator, and generator patterns
javascript iterator, js iterator, iterator javascript, iterator js, javascript iterators, iterators javascript, iterators js, js iterators, iterators and generators in javascript, generator pattern javascript: Iterator …
instanceof in JavaScript: classes, functions, numbers, and the prototype chain
javascript instanceof, js instanceof, instanceof javascript, instanceof js, instanceof, instanceof in javascript, instance of javascript, instance of js, javascript instanceof function, javascript instanceof number: …
JavaScript functions as values: first-class functions and return values
JavaScript functions treated like variables: assign, pass, and return functions; how to return a value from javascript function vs returning a function; map callbacks; object and class methods; first order function in …
JavaScript indexOf: string and array indexOf in JS (indexof javascript)
javascript indexof, indexof javascript, js indexof, indexof js, indexof, indexof in javascript, indexof in js, index of javascript, index of js, index of in js: String.prototype.indexOf, Array.prototype.indexOf, …
JavaScript object has property: Object.hasOwn, hasOwnProperty, and the in operator
javascript object has property, javascript has property, js object has property, object has property javascript, has property javascript, javascript check if object has property, js has property, javascript hasproperty, …
localStorage event listener & storage event: addEventListener('storage') (local storage event listener)
localstorage event listener, local storage event listener, storage event listener, localstorage change event, localstorage events, localstorage event, addeventlistener storage, window addEventListener storage: …
JavaScript lastIndexOf: Get the Last Index in Strings and Arrays
JavaScript lastIndexOf for strings and arrays: find the last index of a value, use fromIndex, handle -1, compare indexOf vs lastIndexOf, and understand strict equality, NaN, and sparse arrays—with runnable Node examples.
JavaScript infinite loop: forever loop syntax, bugs, and how to avoid them
javascript infinite loop, infinite loop javascript, infinite loop in javascript, infinite loop js, js infinite loop, forever loop javascript, javascript endless loop, how to make an infinite loop in javascript, …
Linked list in JavaScript & JS: ListNode, build, traverse (linked list javascript)
linked list javascript, linked list js, javascript linked list, linked list in javascript, js linked list, linkedlist javascript, javascript linked lists, listnode js, javascript listnode, how to create a linked list in …
JavaScript get width of element: offsetWidth, clientWidth, getComputedStyle, DOMRect
javascript get width of element, javascript get element width, get width of element javascript, js get width of element, js get element width, get element width javascript, get width of element js, javascript element …
JavaScript get element & find element: getElementById, querySelector, collections
js get element, javascript find element: getElementById, querySelector, querySelectorAll, getElementsByClassName, getElementsByTagName. Snippets use `{run=false}`—run with happy-dom/jsdom and the sample HTML in the …
JavaScript if not: logical NOT (!), if (!condition), and not in checks
javascript if not, if not javascript, if not in javascript, js if not, if not js, if not in js, not in javascript, not in js, javascript not, js not: logical NOT (!), if (!x), !==, !=, !(key in obj).
JavaScript Map Size: Check Number of Entries in a Map
JavaScript Map size: use map.size (not length), empty checks, and how set/delete/clear and duplicate keys change the count. Short notes after snippets describe expected console output.
JavaScript join() Method: Convert Array to String
JavaScript Array.prototype.join(): default comma separator, custom separators, empty string joins, null/undefined and sparse slots, nested arrays, and split/join patterns. Short notes after snippets describe expected …
JavaScript map() with Index: Use the Array Map Index Argument
JavaScript map() with index: use the second callback argument in Array.map(), return index-based values, access the original array via the third argument, and understand sparse array holes.
JavaScript Integer Division (Divide Without Remainder Explained)
Learn how to perform integer division in JavaScript and divide numbers without remainder. This guide explains methods like Math.floor(), Math.trunc(), bitwise operators, and BigInt division with practical examples, edge …
JavaScript Math.sign(): Check Positive, Negative, Zero and NaN
JavaScript Math.sign(): -1, 0, 1 (and -0), NaN for non-numbers, and common sign-check patterns.
JavaScript Math.trunc(): Remove Fractional Digits
JavaScript Math.trunc(): drop the fractional part toward zero, compare trunc vs floor/ceil/round, and NaN behavior.
