Polyfill interview questions
Practice 46 questions on polyfill. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
46 questions
- JavaScriptCoding exercise
Array findLast / findLastIndex
EASYImplement findLast and findLastIndex — scan an array from the end for the last element matching a predicate.
15 minPractice - JavaScriptCoding exercise
Array.prototype.at
EASYImplement Array.prototype.myAt — return the element at a given index, supporting negative offsets from the end.
15 minPractice - JavaScriptCoding exercise
Array.prototype.every
EASYImplement Array.prototype.every — return false as soon as an element fails the predicate, true when empty.
15 minPractice - JavaScriptCoding exercise
Array.prototype.filter
EASYImplement Array.prototype.filter from scratch as a method on the array prototype.
15 minAmazon · Apple · Canva +1Practice - JavaScriptCoding exercise
Array.prototype.flat
EASYImplement Array.prototype.flat — flatten nested arrays to a given depth (default 1, Infinity for all levels), dropping holes.
15 minPractice - JavaScriptCoding exercise
Array.prototype.forEach
EASYImplement Array.prototype.forEach — run a callback on each element as (value, index, array), skipping sparse holes.
15 minPractice - JavaScriptCoding exercise
Array.prototype.includes
EASYImplement Array.prototype.includes — test membership with SameValueZero so NaN matches, honoring negative fromIndex.
15 minPractice - JavaScriptCoding exercise
Array.prototype.indexOf
EASYImplement Array.prototype.indexOf — first index of a value by strict equality, supporting a negative fromIndex.
15 minPractice - JavaScriptCoding exercise
Array.prototype.some
EASYImplement Array.prototype.some — return true as soon as any element passes the predicate, false when empty.
15 minPractice - JavaScriptCoding exercise
Map.groupBy
EASYImplement Map.groupBy — group an iterable into a Map whose keys can be any value, preserving key insertion order.
15 minPractice - JavaScriptCoding exercise
Object.entries
EASYImplement Object.entries — return an object's own enumerable string-keyed [key, value] pairs in insertion order.
15 minPractice - JavaScriptCoding exercise
Object.fromEntries
EASYImplement Object.fromEntries — build an object from any iterable of [key, value] pairs, with later keys winning.
15 minPractice - JavaScriptCoding exercise
Object.is
EASYImplement Object.is — same-value equality that treats NaN as equal to itself and keeps +0 distinct from -0.
15 minPractice - JavaScriptCoding exercise
Promise.race
EASYImplement Promise.race so it settles with the outcome of whichever input promise settles first.
15 minGoogle · RobloxPractice - JavaScriptCoding exercise
Promise.reject
EASYImplement a function that returns a Promise already rejected with the given reason.
15 minByteDance · Google · Meta +1Practice - JavaScriptCoding exercise
String.prototype.padStart
EASYImplement String.prototype.padStart — pad a string to a target length on the left, truncating a multi-char pad.
15 minPractice - JavaScriptCoding exercise
String.prototype.repeat
EASYImplement String.prototype.repeat — join a string n times, throwing RangeError on a negative or infinite count.
15 minPractice - JavaScriptCoding exercise
String.prototype.trim
EASYImplement String.prototype.trim — strip leading and trailing whitespace, including Unicode whitespace, from a string.
15 minPractice - JavaScriptCoding exercise
Array.fromAsync
MEDIUMImplement Array.fromAsync: build a promise of an array from a sync or async iterable, awaiting each value in order.
30 minPremium questionPractice - JavaScriptCoding exercise
Array.prototype.concat
MEDIUMImplement Array.prototype.myConcat — merge arrays and values into a new array, spreading nested arrays one level deep.
25 minApplePractice - JavaScriptCoding exercise
Array.prototype.find
MEDIUMImplement Array.prototype.find and findLast — return the first or last element matching a predicate, or undefined.
25 minPractice - JavaScriptCoding exercise
Array.prototype.flatMap
MEDIUMImplement Array.prototype.flatMap — map each element, then flatten the mapped results by one level.
25 minPractice - JavaScriptCoding exercise
Array.prototype.map
MEDIUMImplement Array.prototype.myMap — return a new array with the callback applied to each element, skipping holes.
25 minAmazon · Apple · ByteDance +2Practice - JavaScriptCoding exercise
Array.prototype.reduce
MEDIUMImplement Array.prototype.myReduce — fold an array down to one value, handling sparse arrays and missing initial values.
25 minAdobe · Amazon · Apple +4Practice - JavaScriptCoding exercise
Array.prototype.reduceRight
MEDIUMImplement Array.prototype.reduceRight — fold an array right-to-left, throwing on an empty array with no initial value.
25 minPractice - JavaScriptCoding exercise
Array.prototype.splice
MEDIUMImplement Array.prototype.splice — remove and insert elements in place, returning the removed ones, with clamped indices.
25 minPractice - JavaScriptCoding exercise
Base64 atob / btoa
MEDIUMImplement base64 encoding and decoding from scratch — pack bytes into 6-bit groups, map to the alphabet, and handle padding.
35 minPremium questionPractice - JavaScriptCoding exercise
Deep Freeze
MEDIUMRecursively freeze an object and every nested object and array, making the whole structure deeply immutable.
25 minPremium questionPractice - JavaScriptCoding exercise
ES5 Class Inheritance
MEDIUMWire up classical inheritance the pre-class way — link prototypes with Object.create, restore the constructor, and call the superclass constructor.
30 minAmazon · Google · Meta +1Practice - JavaScriptCoding exercise
Function.prototype.apply
MEDIUMImplement Function.prototype.myApply — invoke the function with a given `this` and an array of arguments.
25 minPractice - JavaScriptCoding exercise
Function.prototype.bind
MEDIUMImplement Function.prototype.myBind — return a new function with a fixed `this` and optional preset arguments.
25 minAdobe · Amazon · Atlassian +3Practice - JavaScriptCoding exercise
Function.prototype.call
MEDIUMImplement Function.prototype.myCall — invoke the function with a given `this` and a list of arguments.
25 minPractice - JavaScriptCoding exercise
getElementsByClassName
MEDIUMImplement a function that returns all DOM elements containing every one of the specified class names.
25 minAmazon · Discord · Dropbox +2Practice - JavaScriptCoding exercise
Immutable Array Methods
MEDIUMImplement the ES2023 change-by-copy trio — toSorted, toReversed, and with — that copy an array instead of mutating it.
30 minPremium questionPractice - JavaScriptCoding exercise
Iterator Helpers
MEDIUMBuild lazy, chainable iterator helpers — map, filter, take, drop, and flatMap — that pull one value at a time.
35 minPremium questionPractice - JavaScriptCoding exercise
JSON.stringify
MEDIUMImplement a function that converts a JavaScript value into its JSON string representation.
25 minAmazon · Google · Meta +4Practice - JavaScriptCoding exercise
Object.assign
MEDIUMImplement Object.assign — copy own enumerable string and symbol properties from sources onto a target, skipping nullish.
25 minPremium questionPractice - JavaScriptCoding exercise
Promise.all
MEDIUMImplement Promise.all so it resolves with an array of results or rejects on the first rejection.
25 minAmazon · Birdeye · ByteDance +13Practice - JavaScriptCoding exercise
Promise.allSettled
MEDIUMImplement Promise.allSettled from scratch, resolving to an array of fulfilled or rejected outcomes for each input.
25 minPractice - JavaScriptCoding exercise
Promise.any
MEDIUMImplement Promise.any so it resolves with the first fulfilled value or rejects with an AggregateError.
25 minPractice - JavaScriptCoding exercise
Promise.resolve
MEDIUMImplement Promise.resolve — wrap a value in a fulfilled promise, returning thenables unchanged and adopting their state.
25 minByteDance · Google · TikTokPractice - JavaScriptCoding exercise
Promise.withResolvers
MEDIUMImplement Promise.withResolvers — return a new promise alongside its external resolve and reject functions.
25 minMetaPractice - JavaScriptCoding exercise
String replaceAll / matchAll
MEDIUMImplement replaceAll and matchAll — replace every occurrence of a substring or global pattern, and iterate every match with its capture groups.
35 minPremium questionPractice - JavaScriptCoding exercise
String to Number (parseInt)
MEDIUMReimplement JavaScript's parseInt — skip leading whitespace, read an optional sign and radix prefix, consume valid digits for the base, and stop at the first invalid character.
25 minPremium questionPractice - JavaScriptCoding exercise
The new Operator
MEDIUMImplement newOperator — reproduce the four steps the new keyword performs, honoring the object-return override.
30 minPremium questionPractice - JavaScriptCoding exercise
JSON.stringify II
HARDImplement JSON.stringify with full spec support including replacer, indentation, and circular reference detection.
40 minAmazon · Google · Netflix +1Practice