JavaScript Refresher and Detailed Study - Table of Contents for Post Series
Last updated on 12 Nov 2026
Note: My related web dev post: HTML Refresher and Detailed Study - Table of Contents for Post Series, April to July 2026.
Introduction
Period: 3 August 2026 to 12 November 2026 (part-time, ongoing)
This is a refresher cum detailed study on JavaScript topics that I had quickly studied perhaps in end 2023 and early 2024, and then referred to when needed for software development learning or work I was doing.
I had used W3Schools JavaScript tutorial in the past and even recommended it in my Jan. 2024 blog post: Roadmap to Learning Full Stack (MERN) Web Development Beginner Level Through Free Online Tutorials.
But Gemini recommended JavaScript.info as best for a thorough refresher. So I used JavaScript.info.
I have put up a series of longish blog posts related to this JavaScript refresher and detailed study, with each post having a Contents section with internal links to the sections. This post lists all the Contents of all the posts in the series with the internal links going directly to the related section in the post.
This refresher and detailed study is ongoing.
JavaScript Refresher and Detailed Study - Part 1
Published: 06 August 2026. Study & Dev work period: 3 to 6 Aug 2026
Contents
- Introduction
- Strict mode in vanilla JS apps
- Symbol data type rarely used in typical web application development (as against libraries like React)
- Regular equality (==) is rarely used in modern JS coding; Strict equality (===) is the standard practice
- Curly Braces are commonly used for
ifSingle-Statement Blocks except for early returns / guard clauses at the top of a function - Nested Ternary statements formatting; Better options of object lookup or switch statement
- React: 'switch' is a statement and so illegal inside JSX; Multi-level ternaries are expressions which are valid in JSX and so commonly used; inline object lookup is a clean-code option
- Boolean(value) is cleaner than !!value
- Chaining nullish coalescing operator (??) across 3 or 4 variables is quite rare in modern React and application code
- Explanation of Destructuring code in above response
- ?? vs || in JavaScript expression chains
- Curly braces {} overload in JS/React: Object literal, Destructuring (data unpacking), block scope/code block, JSX interpolation expression
- break, continue and labels - are they used in production JS code?
- Nullish coalescing operator is not a good name; First not nullish operator may have been better
- Between Math.pow and exponentiation operator (**), the latter is more commonly used in modern codebases
- Functions being objects in JS is strange to me as early 2000s C/C++ handled it differently
- Custom properties attached to a function in JS is rarely used in web app code but frameworks/libraries may use them
- Callback functions are not a special type of function in JavaScript; they are just functions that are passed as arguments to other functions
- Modern React uses arrow functions across both single-line and multi-line handlers for stylistic consistency and team conventions
- Function expressions are rarely used in modern React or Vanilla JavaScript development
- Transpiling and Polyfilling
- Nice crisp definition of properties from https://javascript.info/object
- object literal syntax (
{}) is used exclusively in modern development and notnew Object() - In regular app development, quotes around multi-word property keys are avoided entirely in favor of unquoted
camelCase - $ and _ are the only special characters that can be part of variable name or unquoted property key
- Square brackets perform an expression evaluation step before doing property lookup
- Property names can be JavaScript reserved words (from ES5 (2009))
- JavaScript deliberately evolved to maximize developer productivity and expressive power, trading C's strict procedural explicitness for a fast-moving, programmer-centric style
Object.keys(obj).length === 0is the idiomatic, modern JavaScript way to check for empty object- Ensuring that a value is numeric is non-trivial in JavaScript -
typeof val === 'number' && !Number.isNaN(val)lets Infinity through ,Number.isFinite(val)is safe - Square bracket
[operator works the same for objects and arrays as array is implemented as an object - Why JS arrays were implemented as objects
- All C++ classes and structs do not have equivalence to JavaScript bracket expression evaluation (dynamically); Specific C++ classes like std::map provide equivalent functionality
- Acceptable Computer Science terminology for JavaScript object - Associative Array/Dictionary usually implemented as Hash Table but at times implemented differently for optimization
- Refresher focused on learning web dev topics I need; Prototypes Are Mostly Legacy and can be skipped
- Classes were not used in the modern React/Next.js apps I developed
- Classes were not used in the Vanilla JS apps AI tools provided me; Is 'class' used in vanilla JS app dev (as against library/framework dev)
- Will cover JS classes at overview level and try to map my 2000s OOP C++ knowledge base to JS classes
JavaScript Refresher and Detailed Study - Part 2
Published: 15 August 2026. Study & Dev work period: 6 to 7 Aug 2026; 13 to 16 Aug 2026
Contents
- Copying reference to an object; Copying object - shallow copy and deep copy
- Non-trivial confusion in JS due to same variable at times holding contents directly, but at times only holding a reference to the contents
- Modern frontend web development, especially within React ecosystem, uses Functional Programming (FP) and not traditional Object-Oriented Programming (OOP)
- React 'Functional Components' is bad terminology from traditional Software Engineering perspective - they are simply 'Render Functions'
thisis rarely used in modern React, Next.js, or Astro applicationsthisin Arrow functions (ES6(2015)) has lexical scope (its container in code);thisin standard JS functions has dynamic scope (who called it)thisis used in libraries to provide function chaining- Limited usage of
newin modern web apps for legacy APIs (e.g. Date, URL); Modern libraries/frameworks prefer JS factory function which returns created object - Constructor functions are rarely used in modern web apps
- In optional chaining (
?.) we don't need to worry about last property name in the chain - Optional chaining variants of
?.()and?.[]do get used quite a bit in modern web app dev Symbolis rarely used in web app dev code but used by libraries/frameworks- Object to primitive conversion can be ignored for web app dev
- toFixed() discards unwanted precision but is problematic for sensitive fractional calculations (e.g. financial) ; Integer Math is safe (e.g. using cents instead of dollars); decimal.js, currency.js library alternatives
- To check if a string contains valid numbers: Modern web dev uses Regex or libraries like validator; You cannot use
Number.isNaN()but can use isNaN(); - In Zod you have to use Regex to check for string having valid number
- In enterprise apps,
parseIntorparseFloatare rarely used for general data validation, API parsing, or handling user input; Serious codebases use them for niche tasks like parsing CSS/DOM values - Unary
+is rarely used in modern codebases, Number() is preferred; Performance-focused exception cases where it is used - Never mutate parameters philosophy of modern JS codebases
- at(-1) to get last item in array approach (negative indexing approach) is somewhat new (ES2022) but is being used in recently created/updated codebases
- Creating sparse arrays (arrays with holes) is not recommended even if JS allows it
- forEach passes three parameters to function even if only function reference without () is used as parameter to forEach
- Higher-Order Functions and Declarative Programming
forEach- Declarative Programming term seems like exaggeration- No external state, no mutation, new data structure returned and so can be chained - great features but still 'declarative' seems to be exaggeration
- JavaScript array methods not fully declarative like SQL - they simply offer a declarative interface wrapped around an imperative callback
- array.map() method name seems odd as it does transformation whereas Map class is a key-value pair
- array sort method modifying the array in place seems unusual as compared to 'declarative' methods like filter and map; toSorted() newer method
- Backward compatibility requirement seems to have created some 'landmines' in JS programming features; TypeScript and ESLint are used to avoid using such 'landmines'
- splice() is a strange method; Better to avoid using splice; toSpliced() is a safer alternative
- Javascript.info cheatsheet on array methods; Addendum provided by Gemini covering newer methods
- Semantic intent of array find(): need to extract object; Semantic intent of array some(): need to only know if array has one or more matches for condition
- JS iteration methods handle empty slots in sparse arrays in different ways;
forEachignores;mappreserves;filterstrips out; - Empty slot is different from undefined! Better to avoid empty slots and Array() legacy constructor which creates empty slots; Array.from() creates array without empty slots
- Newer methods do not treat empty slots specially and treat them as if they contain undefined; But how does one remember which method treats empty slot as undefined?
- MDN Array deep copy example is inappropriate and misleading; MDN documentation slips up at times
- Nested array join cannot be said to be recursive even though, due to type coercion, join is called for nested arrays but with default parameters
- React TypeScript code may be good but sucks time; Some small team web dev projects with quick delivery constraints may prefer React JavaScript instead of React TypeScript
- Array flat() method with default depth of 1: Nested arrays use case
- Skipping flatMap() method for now; Gem example of flatMap() to get all tags of blog posts in a single array
- Javascript.info section: 'Translate border-left-width to borderLeftWidth' solution fails on some edge cases
- Array
toSorted()is modern approach instead ofslice().sort() - Using Template Literal (backticks) is preferred over string concatenation
- For
for...ofloops, industry standard is to useconstrather thanlet:for (const item of arr) { - Local mutation of accumulator in reduce is acceptable exception for performance reasons; Set is superior to reduce for unique arrays
- Create keyed object from array:
reduce()with local mutation approach and modernObject.fromEntries()approach - Clearing up confusion about local mutation in array reduce()
JavaScript Refresher and Detailed Study - Part 3
Published: 04 September 2026. Study & Dev work period: 27 to 30 Aug 2026, 3 to 4 Sep 2026
Contents
- First look at iterable in javascript.info
- Quick look at MDN: Iterators and generators; Did not see iterators and generators in React JS codebases I saw
- Why
this.is needed in the iterable examples of javascript.info - What's needed to make an object iterable?
- Javascript.info range iterator case does not really iterate over range object
- Vanilla JS program could leverage run to completion guarantee but that may not be recommended in React JS programs
- Dangers of merging iterator into the iterable
- JavaScript surrogate pair (e.g. most emojis) causes length property of string to give inaccurate string length; Array.from() fixes it
- Vast majority of apps still use standard
.lengthproperty; Array.from() is slower and.lengthis good enough for most use cases - Modern C++ std::string too faces the same issue; Special functions provide solution but at performance cost
- Using break in loop is acceptable as guard clause in modern codebases
- array-like only needs to have length property. Indexed properties are optional
- Global Symbol object and the Symbol.iterator primitive; Bracket notation [Symbol.iterator] is necessary to use it.
- Value word overloaded in JavaScript which can confuse newbies
- Implicit stringification of object to
"[object Object]" - Map and Set examples of javascript.info
- Big-O Time Complexity (performance) in context of JS Map and Set
- When to use Map and when to use Object
- When to use Set and when to use Array
[...new Set(arr)]is overwhelmingly preferred overArray.from(new Set(arr))in modern JavaScript and React codebases.- iterable object is the right term for what map.keys() returns
- WeakMap and WeakSet
- Arrays also have keys(), values() and entries() methods like Map and Set
- Global Object constructor of plain objects supports static keys(), values() and entries() methods which take in object as parameter and return arrays not iterators
- for...of is the recommended way to iterate over an array; Array supports for...in but using that is not recommended
- JS array is very different from C++ array and more like highly optimized
std::vectorcombined with a built-in algorithmic toolkit - Inlining
Object.values(user)directly within thefor...ofstatement is preferred in modern JavaScript - Object transformation pipeline code in modern JS:
Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, value * 2])) - Performance aspect of using reduce for summing a numeric value as against using imperative
for...ofloop - Why parentheses are needed in
({title, width, height} = {title: "Menu", width: 200, height: 100}); - Nested destructuring is not recommended to use in production code
- For functions accepting optional configuration objects -
function showMenu({ title = "Menu", width = 100, height = 200 } = {}) {- pattern is recommended - For reducing down to a primitive, use
reduce. For tracking complex state across iterations, use imperative loop - Swap variables pattern -
[guest, admin] = [admin, guest];- is widely used - Node.js does not have simple prompt statement;
readline/promisesis built-in but needs some code; Third-party libs provide such functionality - Use browser console or snippets to run tutorial code that uses prompt
- Options Object parameter pattern (
showMenu({ title, width, height } = {})) trades the brevity of standard function calls for structural flexibility - Rest pattern for older browsers needs Babel to transpile the code and not polyfill it
JavaScript Refresher and Detailed Study - Part 4
Published: 10 September 2026. Study & Dev work period: 5 to 9 Sep 2026
Contents
- JavaScript Date objects represent a single moment in time in a platform-independent format and is timezone-agnostic - MDN
- JS .toString() output always uses GMT and not UTC due to historical reasons
- By default, alert uses .toString() method on Date objects showing local time but console.log on node.js uses .toISOString() which shows absolute UTC time
- Date object always stores date time in UTC (Absolute UTC, UTC+0) whose value is projected/converted to local date time or vice-versa for output/input purposes
- JavaScript Date time string format
- Main ways in which Date constructor can be used to create a new Date object; Date constructor views parameters as UTC or local time based on number of parameters with one exception
- Creating date object with date only component parameters viewed as local date
- Date constructor month parameter strangely is 0 indexed due to historical reasons
- Issue of Mutability of set methods of Date object (Value Semantics expected): Inconsistent with modern languages like C#, Java and Python; New Temporal API fixes it
- Date time component segment silent 'carry over' or 'borrow from' aspect of JS Date
- date-fns library is preferred over native Date arithmetic; Temporal API is another option but that is new and so browser support may be limited
- Date.toISOString() is badly named as name implies that it simply prints the string in ISO format; As it prints time always in UTC it should have had UTC in its name
- Why did node.js not use local time for console.log for date variables by default, and thus be consistent with browser?
- Better 'Format the relative date' solution than javascript.info tutorial solutions
- Date is a built-in object. Creating a Date object requires using new.
- Constructor function in JavaScript
- new and prototype were part of JavaScript 1.0 in 1995
- None of the languages I worked with in 1984 to 2002 - C++, C#, PL/1, C, COBOL, BASIC (including Microsoft Visual Basic) and very little bit of Java - were protoype based
- JavaScript prototype is based on Self language
- MDN Global Objects (Built-in objects) page
- undefined, Infinity and NaN global value properties are there due to legacy reasons
- Global isNaN() acts like isNotNumeric and is retained due to legacy reasons. Number.isNaN() acts as expected
- Recommended way in JS to check if string has only numeric digits is to use Regular Expressions. Validator.js, HTML5 validation, Zod are useful for such checks
- globalThis global property is a standardized, environment-agnostic way to get global this object
- Global value properties are not global objects
- Global objects term seems to be little loose; Global this object has member objects which seem to be referred to as global objects
- In ES modules
thisat global level evaluates toundefined.globalThiswill evaluate to global this object - Function properties of global object; JS function-as-object quirk; eval() exception related to Direct vs. Indirect
- Legacy reasons for function properties of global object
- Overview of many member objects of global object
- Why have BigInt global object as well as BigInt primitive? Similar question for other primitives
- Lack of consistency on when to use new and when not to, for member objects of global object (global objects)
- All properties and objects of global object are created and available before app JavaScript code starts execution
- The phrase 'using String as a constructor' implies String function is being invoked with new
- MDN Global Objects page does not mention what is recommended to use or not recommended but individual property pages of Global object members does mention it
- Different approach of C++ (#include) and JavaScript for standard/built-in objects; For user/library objects JS uses ES Modules (import) which has some approach similarity with C++ (#include)
- Built-in digression took lot of time; Postponing prototype digression
- String implicit wrapper test code; Modern JavaScript engines (like V8) bypass creation of wrapper objects for primitives
- JavaScript engine tags all primitive data variables with an internal type identifier which helps to identify associated wrapper objects; null and undefined are exceptions - no wrapper objects
- C++ world frowns upon 'under the hood' convenience tricks like auto-boxing but they are fine in JavaScript; TypeScript enforces strict typing like C++
- JavaScript does not do function parameter type coercion like C++; TypeScript shows static function parameter type mismatch errors at compile time but at runtime only JavaScript code is present
JavaScript Refresher and Detailed Study - Part 5
Published: 20 September 2026. Study & Dev work period: 10 Sep 2026, 18 to 20 Sep 2026
Contents
- How common is it to have toJSON() method defined for an object when doing JS web app dev
- For browser side debugging, console.log for objects is good; For terminal debugging, JSON.stringify() with space 2 parameter or console.dir handles deeply nested objects
- Date objects are serialized to string by default by JSON.stringify() but not deserialized to date object by default by JSON.parse(); Solutions to this issue
- Next.js uses custom React serialization format that supports
Date,Map,Set, and evenPromiseobjects. JSON.stringify() and JSON.parse() do not handle them properly. BigInt issue - JS namespace object is not really a POJO - Plain Old JavaScript Object
- Informal definition of JS namespace object
- MDN page on JSON imprecisely refers to "All properties and methods of JSON"
- JavaScript does not have proper
namespacemechanism like C++ has; Namespace objects and ES6 Module imports are recommended way to handle namespaces in JS - MDN JSON page uses
staticinformally; JavaScript hasstatickeyword in context ofclass; MDN is a Wiki, Not a Spec - ECMA specification for JSON object does not use static word for JSON object functions
- console.log shows
<ref *1>as a flag to later tell a circular reference is pointing to it - Recursion and stack - Intro
- Using Array reverse() mutating method is recommended for temporary arrays within function for efficiency
- Recursion related hard stack limit: Node.js and most modern browsers typically throw a fatal
RangeError: Maximum call stack size exceededanywhere between 10,000 and 15,000 stack frames - In modern enterprise JS: Shallow data - recursion is safe; Linear/Unbounded data - don't use recursion
- The Architectural Heuristic: Iteration vs. Recursion in JavaScript
- Depth check before using recursion is anti-pattern; If recursion is required for linear/unbounded data, simulated call stack on heap is better solution
argumentsobject is not used in modern JavaScript, having been completely superseded by rest parameters (...args)- spread syntax
[...str]is preferred for straightforward conversions;Array.from()is used when you need to transform the data during the conversion - To copy objects, in modern JS apps, spread
{ ...obj }is the absolute default for all state updates and data transformations;structuredClone()is used only in exception cases - spread-and-overwrite pattern is common in modern JS codebases; Efficiency is not an issue
- Array spread works on iterables including Map and Set
- Object spread is somewhat different from Array Spread;
applyandObject.assignis ignored in modern JS in favor of the spread syntax - Modern JS coding style for temporary loop variables whose values have to be remembered across loop iterations: Declare outside loop with function scope
- JavaScript closure informal definition
- JavaScript closure improved informal definition
- currying - Functional Programming concept
- closure-returning pattern applied to
filterormapis used only in some cases in modern JS - Lexical Environment is created per code block; special execution rule for
for (let ...)that automatically binds a fresh Lexical Environment per iteration - IIFEs are not obsolete - they are used in modern React app codebases
- Function Arity inspection (number of named parameters declared in its signature) is rarely used in modern JS apps but modern JS libraries use it
- Using function properties to store active application state is not recommended in modern JavaScript apps with some exceptions
- Named Function Expression (NFE) is useful for recursion
- Named exports that are imported as needed and class instances are the norm for JS libraries today; Using function properties in JS libraries API is viewed as an outdated anti-pattern
- Dot operator chaining is commonly used but function () chaining is used rarely in modern JS app code
new Functionis effectively banned in modern JS app code due to security issues
JavaScript Refresher and Detailed Study - Part 6
Published: 3 October 2026. Study & Dev work period: 26 to 27 Sep 2026, 29 Sep 2026
Contents
setTimeoutautomatically cleans up after itself the moment it finishes executing;clearTimeoutis needed only to stop it before its timer runs out- Nested setTimeout: Differences between a browser's execution environment and Node.js's backend event loop
- 'Output every second' exercise using setTimeout and setInterval
- caching decorator pattern which is referred to in modern JS as memoization
- Function object call and apply methods to specify 'this' passed to a called function
- Method borrowing for the arguments object is obsolete in modern JS
- Similar consecutive lines using
...operator but one is rest operator and another is spread operator applyis slightly more efficient thancallin one scenario related to elimination of middle unpack/repack cyclereturn func.apply(this, args);acts as universal pass-through which adapts to however the wrapper was called—as method with an object context, or as standalone function withundefinedcontext- Adding property to function (object)
- Delaying decorator exercise solution
- Definition of debouncing
- bufferAndDebounce wrapper - previous version
- Before Array.flat() introduced in 2019, using spread operator to convert multi-dimensional arrays to 1D array
- spread operator cannot be chained
- bufferAndDebounce wrapper - final version
- debounce wrapper with Status message example
- Decorator structural design pattern term is used for all wrapper behaviors like memoize, debounce, throttle and delay
- throttle exercise solution using nested setTimeout
- Passing a function reference like
user.sayHistrips away the object context .bind()is practically extinct in modern React and vanilla JavaScript application codebases- Result of bind function is another object which does not have custom properties of original function
- Lazy Evaluation via Closure
() => user.loginOk()with user defined as const is preferred in modern JS app codebases over Eager Evaluationuser.loginOk.bind(user) - forEach runs functions with this=undefined by default
- Arrow functions are used not only for short pieces of code but also to define massive, complex React components or deep Node.js controllers
- Property descriptors are not used in modern JS app dev; They are used in libraries/frameworks
- Property accessors (getters and setters) are not created but they are used at times via APIs in modern JS app dev
JavaScript Refresher and Detailed Study - Part 7
Published: 3 October 2026. Study & Dev work period: 29 Sep to 3 Oct 2026
Contents
- Prior exchanges with Gemini on JS prototype inheritance
Object.keys(),Object.values(), andObject.entries()are preferred overfor...inin modern JS app codebases- Because
Object.keys()andObject.entries()natively filter out the prototype chain, the classichasOwnProperty()guard is obsolete for iteration - Manually wiring up prototype chains using
__proto__orObject.setPrototypeOf()is considered an anti-pattern in modern application development - ES6 Classes are used instead of
F.prototypepattern in modern JS apps Object.prototypecontains zero data properties and only a small handful of methods- Viewing prototype chains in Chrome debugger
- Method borrowing (of methods like Array.prototype.join) is not used in modern JS app codebases
- Though setting prototype at creation via Object.create() is fast, modern teams rely on class and extends for inheritance because it provides syntactic safety
Mapobject has largely replaced the need (exceptions are there) for theObject.create(null)trick for application-level code- Modifying constructor function's prototype does not trigger the JavaScript engine optimization penalty
- JavaScript inheritance is based on objects whereas C++ inheritance is based on classes which are only blueprints for objects and not objects
- How
Array.prototype.push()comes into play forlet arr = [1, 2, 3];...arr.push(4); - Class field syntax (
click = () => { ... }) creates arrow function directly inside the constructor, capturingthisof constructor in closure, if needed - Class syntax translation to
F.prototypepattern - Constructor functions have internal
[[Prototype]](function's own inheritance) and.prototypeproperty (payload for future instances) - Default .prototype for constructor functions points to middleman holding-pen dictionary object
- new object created by constructor function and constructor function itself live on completely parallel, distinct inheritance tracks in memory
- .prototype based inheritance chain in object - Chrome debugger display
- Class and extends based inheritance chain in object - Chrome debugger display
- Standard functions: .prototype dictionary object is created, so can be invoked with
newbut should not be; Arrow functions: .prototype not created, so cannot be invoked withnew - Chrome debugger follows object references (pointers) and shows properties of referred object
- 'shared dictionary': Rabbit.prototype (pointing to) animal, will be [[Prototype]] of all objects created by
new Rabbit(arg)expression and so animal (object) will be 'shared dictionary' among created objects - 'Blueprint payload' for new objects involves constructor function and object pointed to by
[[Prototype]]internal property of created objects - Adding methods to 'shared dictionary' using
Fn.prototype.methodNamesyntax became standard as devs rarely replaced entire prototype with standalone object - Legacy JavaScript Inheritance example using Animal and Rabbit constructor functions
- Syntax
fn() { ... }inside an object literal is known as ES6 concise method syntax - Modern React codebases structurally bypass the need for concise object method syntax
- Arrow function in object literal (
{ ... }) will not pick upthisfrom the associated object, because object literals do not create a lexical scope. - Writing properties does not use prototype chain
[[Prototype]]; Only reading properties uses prototype chain - Ordinary function fn() 'inherits' from
Function.prototype(fallback dictionary) and notFunction; All objects (eventually) 'inherit' fromObject.prototypeand notObject - w3schools.com JS tutorial avoided bringing in complication of prototype, which gave me wrong impression about
Objectbeing foundational object (instead ofObject.prototype) - w3schools page talks about Array push() but MDN page mentions Array.prototype.push() which had confused me earlier
- Details of comparison of two references to a function (object)
- V8 engine splits JS function into two distinct memory components: Function Object (Data Heap) and Executable Instructions (Code Space); Function Object has internal C++ pointer to code
- How Number wrapper comes into play for literal numbers
- "Native prototypes" refers to prototype dictionaries attached to JavaScript's built-in factory functions, such as
String.prototype,Array.prototype, andObject.prototype - Objects created with
Object.create(null)are used in modern JS codebases, specifically to create pure, bare-metal dictionary structures (lighter than ES6 Map)
JavaScript Refresher and Detailed Study - Part 8
Published: 9 October 2026. Study & Dev work period: 4 to 9 Oct 2026
Contents
- In classic "Constructor Function" (Pre-ES6)
constructorkeyword is not used while defining them; Constructor function's automatically created prototype property object has a property named 'constructor' - JS dev: "stored in
User.prototype," is shorthand for "stored as property on object referenced byUser.prototype"; classprototypeproperty is non-writable - Simple example of class with per-instance properties and single class level method defined in class's prototype (shared dictionary) object
- Simple Clock constructor function using closure to make internal variable and function private but having inefficiency of function object per instance
- Clock constructor function using closure to make internal variable private and have only one helper function across Clock object instances
- JS does not have implicit object context and so even in object methods,
this.is needed to access property stored on object and its prototype chain - Clock class implementation of previous Clock constructor function examples; class Clock loses data hiding as it does not use private fields
- Clock class with private fields to provide data hiding
- Class methods go to class prototype but class fields go to each class instance (object)
- Double-bracket notation like
[[Prototype]]is convention used by official ECMAScript specification to denote internal engine slots butRabbit.prototype.[[Prototype]]is not valid JS syntax - JS derived class fields initialize after base constructor (super); base class fields initialize before constructor body
- Internal, static
[[HomeObject]]bindings allow safe traversal of the hierarchy (prototype chain) regardless of the runtimethiscontext - Function is a member of the Object type that may be invoked as a subroutine (implements internal
[[Call]]method), Method is a function that is the value of a property - ECMAScript does not mention "pure functions"; In CS "pure function" refers to function that produces the exact same output for a given input and has no side effects
- ES6 Concise Methods
testFn() { ... }have [[HomeObject]] property; Legacy property assignment methodstestFn: function() { ... }do not have [[HomeObject]] property - Standalone functions in JS are related to execution context (without object context) and not function declaration; Top-level function declaration can be invoked in context of object using call()
- Property assignment syntax
testFn: function() {}also creates a method and so cannot be called non-method syntax - JS does not provide any function to dynamically attach
[[HomeObject]]internal property to a function object - Base and Derived class are commonly used terms in JS; Child and parent class terms are also used
- For
class Child extends Parent, internal [[Prototype]] property of Child.prototype will be Parent.prototype, so all properties residing on the Parent's prototype (whether methods or data) are inherited - javascript.info combined with Gemini discussion was good deep-dive; MDN is great for reference but overload for refresher and study
- Any base class method can be called using the
super.syntax; It is not restricted to the method being overridden - Simple 'ExtendedClock' derived class addition to Clock class example code
- Declarative
staticsyntax provides engine-level configurations (non-enumerability and[[HomeObject]]bindings) that cannot be replicated with simple dot-notation assignment - Class
extendskeyword results in two separate prototype chains being wired up: Instance chain for objects and Static chain for classes themselves - Differences between
class Aandclass A extends Object;extends Objectis rarely used in modern JS apps - Underscore prefix
_for properties is used for sharing internal state with subclasses; It is likeprotectedbut as a dev convention and not language feature - Referring to built-in objects like
Array,DateandMapas classes is inaccurate and confusing - 'Array inherits from Object' is imprecise and could be confusing; Array instance (object) inherits from Object.prototype is precise and accurate
- 'static method' term in JS dev has to be interpreted contextually: ES6 syntax OR function in constructor function body
- Understanding dual inheritance chain in MDN pages for built-in objects like Function and Array
- JavaScript engine initializes a standard execution environment - "Realm" - before parsing script, which contains all built-in objects and their corresponding prototype dictionaries
- Code to traverse an object's prototype chain and print it
- Single function accepting multiple entirely different data structures as parameters needs manual type-routing (say, via
instanceof), which is colloquially referred to as "ad-hoc polymorphism" - JS community refers to
Array,Map,Date, and others as built-in classes, even though they are built-in constructor function objects which do not useclasskeyword instanceoffor object hierarchies and standardtypeofoperator for primitive values are used in modern JS apps but isPrototypeOf(), using toString() as extended typeof, and Symbol.toStringTag are rarely used- Modern JS patterns prefer composition over inheritance; Mixin provides multiple inheritance workarounds but is not commonly used in modern JS
JavaScript Refresher and Detailed Study - Part 9
Published: 13 October 2026. Study & Dev work period: 9 to 13 Oct 2026
Contents
- In Node.js,
console.log(err)prints same output asconsole.log(err.stack)as it usesutil.format()...util.inspect()to generate string representation - For local debugging,
console.log(err)orconsole.error(err)is commonly used but for production, remote monitoring tools like Sentry (Sentry.captureException(err)) is appropriate try...catchis used in modern JS apps for API fetch operations and unpredictable third-party data but avoided in standard business logic and React rendering- Custom error classes are rarely used in modern vanilla JS and React JS apps
- Wrapping error objects (
cause) is a modern JS feature which is not commonly used in frontend apps but may be seen in modern backend Node.js codebases - Early 2024 study of Promises
- Asynchronous JS code patterns brief timeline: Callback era (1995 – 2015), Promise standardization (ES2015),
async/awaitsyntactic sugar (ES2017) - Modern JS code usage of callbacks and Promises: Single-Value asynchronous operations - Promises /
async-await; Repeating events and higher-order iteration - Callbacks - Modern JS keeps callbacks flat and prevents hellish nesting of the past
- Callback hell / pyramid of doom code example analysis
- Example asynchronous code with error handling: callback hell (1995 - 2015) way, one callback + Promises (ES2015) way, and one callback +
async/awaitwith try...catch (ES2017) way - Promises: Two-parameter
.thensignature used in special cases but.then().catch()chain provides safety net and so is commonly used; Raw promises are still used in modern JS app code - Thrown exception in Promise handler and Promise rejection are functionally unified; Promise engine automatically intercepts exception in .then() handler and transforms it to Promise rejection
- Promises: Scenarios where two-parameter .then is preferred over .then.catch
- .then() always returns a promise object, and extracting return value from that promise object needs an additional .then()
- Promises: In most real-world applications, final
.then()in chain performs side effect like updating the screen and so its return value is not captured - Promises: Multiple .then() handlers on same promise object are independent subscribers/consumers of same data - this pattern is rarely used in modern JS apps
- Example code to test throw in Promise constructor getting transformed to Promise rejection; .catch method
.catch(fn)is notcatchoftry...catchblock but only a stylistic nod to it - Promises are one of the most complex aspects of JavaScript if not the most complex aspect
- Promises: JS engine automatically forwards unhandled error down the chain to next
onRejectedhandler, and also forwards unhandled successful data to nextonFulfilledhandler - .then() handler without a return statement, returns a Promise object with
undefinedas the wrapped payload (passed to any .then() next in chain) - Internal
[[PromiseResult]]property of promise object is informally referred to as 'result' of promise object by javascript.info tutorial - .then() method returned promise is 'outer' promise as against .then() fulfillment handler returned new promise which is 'inner' promise; Outer promise 'locks in' to inner promise
- Returning promises to build
.then()chains of asynchronous actions; Such chains could additionally have synchronous.then()handlers for data-formatting - Promise
.then()method is synchronous;.then()chain promise objects are created immediately .then()is a synchronous registration operation that succeeds instantly regardless of target Promise's current state- Promise object chain is a dependency chain; Upstream and downstream are common terms to map chain object dependencies
- First/genesis promise object in promise chain is termed informally as root or initial or source promise
- Root promise and outer promises creation step in timeline of execution of promise chain with inner promises
- 1st timer (created by root promise constructor) completion step in timeline of execution of promise chain with inner promises; Outer promise2 getting locked in to inner promise
- Details of linkage of promise1.then() returned promise (promise2) with promise1; PromiseReaction record
- How inner promise returned by promise1.then() fulfillment handler gets linked to outer promise (promise2)
- MDN coverage of outer promise and inner promise and of promises being "resolved" (internal linkage/lock-in of outer promise to inner promise); "States and fates" document defining terms clearly
- 2nd timer (created by promise1.then() handler's inner promise executor fn) completion step in timeline of execution of promise chain with inner promises
- 3rd timer (created by promise2.then() handler's inner promise executor fn) completion step (last step) in timeline of execution of promise chain with inner promises
- Promise Pyramid of Doom is an anti-pattern which can be ignored for modern JS app dev
- Custom Thenable classes is not used typically in modern JS app dev but is used in libraries and frameworks
- Minor point about javascript.info "Bigger example: fetch" section
JavaScript Refresher and Detailed Study - Part 10
Published: 21 October 2026. Study & Dev work period: 13 to 18 Oct 2026
Contents
.catch().then()chaining pattern for error recovery when using raw Promises- Error thrown inside a
setTimeoutcallback executes in different call stack from main app call stack; In browser env, even if not caught, this error does not crash app - 1 - Parallel fetch and response.json operations using Promise.all - limited error handling
- 2 - Parallel fetch and response.json operations using Promise.allSettled - decent error handling
- 3 - Parallel fetch and response.json operations using Promise.allSettled - improved error handling
- 4 - Parallel fetch and response.json operations using Promise.allSettled and async/await with improved error handling
- Comparison of
await response.json()withresponse.json().then() - Promise.any() and Promise.race(): Examples of usage in typical modern JS apps as timeout enforcer and redundancy fallback respectively
- Leftover timeout and lingering promise scenarios with Promise.race()
- Using AbortController for fetch operation with timeout
- Preventing side-effects from un-cancelable lingering promise operation when using Promise.race()
- Cancelling redundant fetch operations when using Promise.any()
- Promise.race() lingering promise timeout handlers delay node.js process from exiting
new Date().toString()is preferred to more efficientDate()as quick informal way to print current date-time on console- Promise basics page of javascript.info oversimplifies
resolveby considering only primitive value being returned byresolveand not promise/thenable - Using Promise.resolve() to ensure function always returns a promise instead of primitive/non-promise object at times and promise object at times.
- Rare scenario of fetch failure reason data where reject method of promise executor function returns a promise
Promise.alldominates React and Next.js codebases as fail-fast nature ofPromise.allis preferred overPromise.allSettled- promisify wrapper function to handle callbacks with variable number of arguments
- Backend: Node.js now provides parallel, Promise-ready versions of all its core libraries; Node.js util.promisify() utility; Custom promisify functions are rarely needed for backend
- Frontend: Modern APIs were designed with promises; Ecosystem promise wrappers like
idbforIndexedDB; Rare cases like Geolocation needs custom promisfy - Usage of synchronous and asynchronous terms in javascript.info tutorial and general JS dev community as against usage of those terms in systems and telecom software in 1980s to early 2000s
- 'Main thread' term in JS refers to 'Window agent main thread' i.e. main thread of browser tab associated process in which the JS app runs
- "Window agent main thread" is in charge of most of the browser tab UI (DOM, CSS layout, JS); "Compositor thread" independently does scrolling, panning and some CSS animations
- In Node.js, the "main thread' is simply called an 'Agent'
- "Executed asynchronously" in javascript.info Microtasks page is more like "queued for deferred exclusive execution" (on Window Agent main thread)
- JS devs get facility of queueing work-units for deferred exclusive execution ("asynchronous execution") without using thread-safe data mutation mechanisms (like mutexes) thus lowering entry barrier
- MDN JavaScript execution model page seems to be important reference for terms like Agent, Stack (execution contexts) and Queue of jobs
- 'Microtask' term is different from 'task' term in JS; Microtasks page of javascript.info confuses by using 'task' term in generic English sense
- async-await javascript.info summary review by Gemini
awaitbrought in suspension of execution context which is not available in raw Promisesasyncfunction returns master wrapper Promise to caller at firstawaitexecution, handles laterawaits in function without impacting master Promise, and resolves master Promise on executing returnawaitin a function needs function to be declaredasyncfor clear contract that function always returns master wrapper promise- Summarizing the equivalence aspect of async-await and raw promises
asyncfunction always returns a separate implicit master promise even if function returns a raw promise- Invoking async function without await when only function side effect is needed and not its return value - fire-and-forget
- Node.js v22 infers .js file having top-level
await(without any package.json in its project) is ES module - javascript.info async-await version of raw promises example needs a top-level await or .then() handler at the end for full equivalence
- javascript.info async IIFE snippet is not fully equivalent to non-IIFE version with top-level await assuming ES module
- Manually crafting custom "thenable" objects in modern application-level JavaScript is exceptionally rare
- Suspending execution flow for short time with
await new Promise((resolve) => setTimeout(resolve, 3000)); fetch('/article/promise-chaining/user.json')appends requested path to origin of server currently hosting web pagenew Promise((resolve, reject) => { ... fn().then(resolve, reject) ...);bypasses inline arrow functions and passes single argument directly to resolve and rejectcustomPromiseAllWaitexercise of javascript.info can be skipped
JavaScript Refresher and Detailed Study - Part 11
Published: 24 October 2026. Study & Dev work period: 21, 23 to 24 Oct 2026
Contents
- Generator functions and
yield-function* fnName(){...}andyield <value>syntax - Two-way yield is rarely used in modern JS apps;
async/awaithas replaced use of two-way generators for writing asynchronous code that 'looks synchronous' for await...ofloop and async generators are not commonly used in frontend apps, but are useful for massive or continuous data pipelines- In modern React JS apps, app files are usually modules but some exception cases may need loading script(s) as global (not modules)
- In ReactJS apps, underlying bundlers like Webpack generate custom JS code to manage and load
.js, .jsx and .tsfiles, and strip out import and export statements; Network efficiency is main advantage - For small vanilla JS apps with one main app source file and possibly one service worker source file, global script is preferred over modular script
- Modern web security heavily restricts inline scripting to prevent Cross-Site Scripting (XSS) attacks
- Module scripts are always deferred; Classic (global) scripts can be deferred and placed near start of HTML page to get parallel load of script and HTML parsing
- Scenarios where a standard non-deferred script is loaded in
<head>: Preventing UI flashes for dark mode, critical polyfills and feature detection, security and redirection, and early analytics asyncscript loading is rarely used for main app logic in modern JS dev but is used for independent drop-in scripts like analytics and ad network scripts- Scripts loaded as classic (global) scripts are blind execution commands that will be invoked multiple times if same script is loaded multiple times, but scripts loaded as ES modules act as strict singletons
- Classic scripts can be loaded from anywhere without CORS headers, while module scripts are strictly blocked unless the cross-origin server explicitly permits it
- Fetch API related CORS is enforced by browser on both classic (global) scripts and module scripts
- 2015 watershed year for web dev: ES2015 added core JS language primitives (Promises and Modules); WHATWG added runtime capabilities (
fetchand strict CORS enforcement) nomoduleattribute is practically extinct in modern web development today- Modules always use strict and so never used 'use strict' in ReactJS; In vanilla JS for non-module scripts, need to use 'use strict' if strict mode is needed
- Bottom Export and Inline Export - Both styles of module exports are used in modern JS apps
- For small standalone tools, AI has made zero-dependency Vanilla JS a robust, sustainable, and frictionless choice over ReactJS which has dependency churn
- Re-export is used in 'Barrel Pattern' in medium-to-large modern JS apps to provide single, clean import path
- JS allows
importandexportstatements to be placed at top or bottom of code but in modern JS apps, by convention, all imports are placed at the top - Dynamic imports are used in ReactJS apps for lazy loading
- Clarification about javascript.info singleton behavior example
- In a module, top-level this is undefined but globalThis is defined
- In modern frontend apps, the
.mjsfilename extension is practically never used ProxyandReflectare not used in standard app dev; Frameworks and libraries may use themeval()should not be used in modern JS apps- Currying example for logging;
const configure = host => port => path => fetch(...)explicit approach is preferred over using generalized wrappers - "Reference Type" is an internal ECMAScript specification artifact; In practical application development, you never interact with the Reference Type itself
BigIntsolves a very specific, niche problem that rarely occurs in everyday UI development- Surrogate pairs and related Unicode topics: Overview level knowledge is enough; Deep dive can be done when needed
WeakRefandFinalizationRegistryare rarely used in JS UI dev
JavaScript Refresher and Detailed Study - Part 12
Published: 12 November 2026. Study & Dev work period: 25 to 26 Oct., 9 to 12 Nov. 2026
Contents
- Intro
- Learning DOM and BOM in some depth is necessary for progress towards becoming Subject Matter Expert in web dev even if typical ReactJS dev may not need it
deferattribute is ignored by the browser on inline scripts; But inline scripts withtype="module"are deferred- Web APIs including DOM API are documented in MDN with WebIDL (Web Interface Definition Language) - e.g.
HTMLTableElement interface- and not JavaScript - Numbers today for JavaScript, Python, C# and any other language use as web frontend programming language
- WebAssembly (Wasm) enables Python (Pyodide) and C# (Blazor) to run in browser
- For standard web frontend apps, Python usage is practically zero; In niche data science and AI applications, Python is used on the frontend (via tools like PyScript)
- Inspecting the DOM document Object in Chrome DevTools: Bypassing Inline Script Breakpoint Quirks
- Labelling anonymous objects - Chrome DevTools uses one way and Console.dir uses a slightly different way
- 'text' object properties are limited but for regular DOM elements like 'div', corresponding object properties are over two hundred!
- Checking DOM elements JavaScript prototype inheritance and mapping it to MDN (WebIDL) documentation
- Chrome implementation of DOM API - No developer-facing reference site
- HTML DOM API MDN page has minor inaccuracy; Correction: HTML DOM tree node can be HTML element or Text node
- HTML DOM API MDN page shows EventTarget as base interface in interface inheritance hierarchy for DOM elements; In JavaScript implementation, we have an additional
Objectobject as base - In JavaScript implementation,
documentglobal object uses prototype inheritance (for behavior) and composition (for structure, e.g.headandbodyproperties) windowglobal object in browser is massive as JavaScript evolved in this way; It has core JS globals, DOM and BOM objects/propertieswindowis used as prefix to access globals at times like safe feature detection and window-specific geometry properties;windowis typically omitted for many globals likealertordocument- Formally HTML tags are the markup syntax like
<div>start tag and</div>end tag; Informally web devs (including javascript.info tutorial) sometimes use 'tag' to refer to HTML element - Few important points from MDN 'Document Object Model (DOM)' page covering essence of DOM
- Interacting with elements in console in DevTools
- head and body properties in document are shortcuts to children of document.documentElement which represents the HTML element
- DOM returns
nullfor non-existent node instead ofundefinedas DOM is a WebIDL specification influenced by strongly typed languages and so is different from JavaScript in this case - Avoid using dangerous feature of browser doing on-demand search for HTML element with
idattribute matching undeclared variable name in JS script code (id-named 'global' variable) - To get an HTML element,
querySelectorandquerySelectorAllmethods have largely become the default standard regardless of app size in modern vanilla JavaScript;getElementByIdis not used typically querySelectorandquerySelectorAllhave almost completely replacedgetElementsByName,getElementsByTagName, andgetElementsByClassNamein modern development- freecodecamp CSS cheatsheet; Has minor typo in
nth-childpseudo-class (incorrectly written asnth-childe) - querySelector and querySelectorAll example CSS parameters for exercise in javascript.info
documentobject's[[Prototype]]->HTMLDocument.prototypeobject whose[[Prototype]]->Document.prototypeobject whose[[Prototype]]->Node.prototypeobject- DOM is fundamentally a strict, memory-managed C++ environment referred to as native code; JavaScript code uses bridge to invoke DOM C++ code
- Neither javascript.info nor MDN seem to cover DOM JavaScript objects using bridge to native code (C++) implementing core DOM functionality
- Examples of JavaScript calling C/C++ code: MDN WebAssembly (Wasm) docs and Node.js C++ addons docs
- WebAssembly (Wasm) C++ code is sandboxed; DOM native C++ code runs in "God Mode" with direct access to V8 JavaScript runtime
- Using
toString()in DevTools console to check whether function is a native code function;Node.prototype.appendChild.toString();gives'function appendChild() { [native code] }' - Function objects like
Node.prototype.appendChildthemselves are the bridge from JavaScript to DOM C++ code; There is noappendChildwrapper function in JavaScript - C++ enumerations like ATTRIBUTE_NODE are implemented as JavaScript primitive constants in
Node.prototype - For checking whether accessor properties like
Node.prototype.childNodeshave native code getters/setters, read property descriptor and dotoString()on its get/set property - Examination of
Node.prototyperevealed that only constants are JavaScript primitive data; Methods and data properties (accessors) are implemented as native code (C++) - Chrome: V8 is standalone JavaScript and WebAssembly engine (compiles to machine code); Blink is web rendering engine (downloads HTML, CSS, and network streams, calculates visual geometry, and paints on screen)
- In typical web application, JavaScript execution in V8 is exceptionally cheap, while DOM manipulation and rendering in Blink are computationally massive
- document.body object can be referred to as JavaScript wrapper object for corresponding C++ object but document.body.appendChild cannot be called JavaScript wrapper function as it is C++ function
Comments
Post a Comment