JavaScript
JavaScript internals, closures, prototypes, async/event loop, and DOM fundamentals.
Function.prototype.bind
Implement your own Function.prototype.bind without calling the native bind method. To avoid overwriting the actual Function.prototype.bind, implement the function as Function.prototype.myBind.
Promisify
Implement a promisify(func) utility that converts an error-first callback-based function into a function returning a Promise, while preserving the call-time `this` context.
JSON.stringify
Implement a simplified jsonStringify(value) function using recursion that converts JavaScript primitives, arrays, and nested objects into a JSON string.
What's the difference between an "attribute" and a "property" in the DOM?
Attributes are defined in HTML and provide initial values; properties live on the DOM node and reflect the current live state.
Why is extending built-in JavaScript objects not a good idea?
Mutating native prototypes (like Array.prototype) risks naming collisions, breaks for...in loops, and conflicts with future language specs.
Why is it, in general, a good idea to leave the global JavaScript scope of a website as-is and never touch it?
Polluting the global scope causes variable collisions between scripts, harder debugging, and unintended memory retention.
Why might you want to create static class members in JavaScript?
Static fields and methods belong to the class constructor itself, ideal for shared utilities, constants, and factory methods.
What's the difference between feature detection, feature inference, and using the UA string?
Feature detection directly checks if an API exists; feature inference assumes unrelated APIs from one check; UA sniffing parses navigator.userAgent.
EventEmitter
Implement an EventEmitter class supporting on(event, listener), off(event, listener), and emit(event, ...args).
getElementsByClassName
Implement getElementsByClassName(root, classNames) to recursively find all descendant nodes containing all specified space-separated class names.
Memoize
Implement a memoize(fn) higher-order function that caches results based on input arguments.
deepOmit
Implement deepOmit(val, keys) to recursively remove all specified keys from nested objects and arrays without mutating the original.
mapAsyncLimit
Implement mapAsyncLimit(iterable, callbackFn, size) to run an async mapper with at most `size` concurrent operations.
getElementsByStyle
Implement getElementsByStyle(root, property, value) to find all descendant nodes whose style[property] matches value.
Deep Copy (deepClone)
Implement deepClone(value) to recursively clone primitives, arrays, Dates, and plain objects.
Debounce
Implement debounce(fn, wait) that delays invoking fn until after `wait` milliseconds have elapsed since the last call.
Throttle
Implement throttle(fn, wait) so fn executes at most once every `wait` milliseconds.
Implement a Trie (Prefix Tree)
Implement a Trie data structure with insert(word), search(word), and startsWith(prefix) methods.
Flatten Nested Object
Implement flattenObject(obj) to flatten deeply nested objects into a single-level object with dot-separated keys.
Promise.any Polyfill
Implement promiseAny(iterable) that resolves as soon as any promise fulfills, or rejects with an AggregateError if all reject.
Function.prototype.call
Implement Function.prototype.myCall(thisArg, ...args) without calling native call() or apply().
Array.prototype.myMap
Implement Array.prototype.myMap(callbackFn, thisArg) to mirror native Array.prototype.map.
Closures & Loop Scoping (var vs let)
Fix a classic loop closure bug so each callback captures its own iteration index instead of sharing the final loop value.
Microtask Queue & Event Loop Order
Predict and verify the execution order across synchronous code, Promise.then microtasks, and setTimeout macrotasks.
Prototype Chaining
Implement createChild(parentProto, ownProps) using Object.create so own properties shadow inherited prototype properties.
JavaScript Blog
10 articlesArticles related to JavaScript.
101 JavaScript Output-Based Interview Questions (With Options & Explanations)
Test your JavaScript fundamentals with 101 output-based MCQ questions covering hoisting, closures, event loop, promises, prototypes, coercion, and this — each with 4 options and collapsible answers.
Caching in React: A Complete Guide to Building Faster Web Applications
Imagine opening an e-commerce website, browsing products, visiting a product details page, and returning to the product listing. Photo by Rubaitul Azad on Unsplash Should the...
Building an EventEmitter in JavaScript
Ever wondered how JavaScript lets you subscribe to events and react when something happens? Let’s build a simple EventEmitter from scratch — a common frontend machine-coding...
Building getElementsByClassName() from Scratch in JavaScript
Ever wondered how to implement a native DOM method yourself? This frontend problem is a great way to practice DOM traversal, recursion, and class matching . Photo by Daniil...
Implementing JSON.stringify() Using Recursion in JavaScript
Ever wondered how JSON.stringify() converts a nested JavaScript object into a string? Let's build a simplified version ourselves! 🚀 Photo by James Harrison on Unsplash The idea...
JavaScript Promisify: Convert Callbacks into Promises
Introduction Before Promises and async/await became popular, JavaScript used callbacks to handle asynchronous operations. For example, a function might call a callback when an...
JavaScript Interview: Implement deepOmit() Without Mutating the Original Object
Problem Statement Implement deepOmit(val, keys) to remove specified keys from an object, including nested objects and arrays, without modifying the original object . For...
Implementing mapAsyncLimit in JavaScript
1. Problem Statement Implement mapAsyncLimit(iterable, callbackFn, size) to apply an asynchronous callback to every array element while limiting the number of tasks running...
Implementing getElementsByStyle() in JavaScript
How can we find all DOM elements that match a specific CSS property and value without using querySelectorAll()? The solution uses DOM traversal and recursion to visit every...
Implementing Throttle in JavaScript: A Beginner-Friendly Guide
In JavaScript, events such as scrolling, resizing, and mouse movement can fire hundreds of times within a few seconds. Continue reading on JavaScript in Plain English »