Object Methods interview questions
Practice 45 questions on object methods. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
45 questions
- EASY
Data Merging
Implement a function that consolidates rows sharing the same user into a single grouped record.
15 minJavaScript - EASY
From Pairs
Implement a function that builds an object from an array of [key, value] pair tuples.
15 minJavaScript - EASY
Function Length
Implement a function that returns the number of declared parameters of a given function.
15 minJavaScript - EASY
jQuery.css
Implement a jQuery-style helper that gets or sets inline CSS properties on a DOM element.
15 minJavaScript - EASY
Key By
Implement lodash keyBy — index a collection into an object keyed by an iteratee's return, keeping the last item for each key.
15 minJavaScript - EASY
Object Map
Implement a function that returns a new object with every value transformed by a mapper callback.
15 minJavaScript - EASY
Object.entries
Implement Object.entries — return an object's own enumerable string-keyed [key, value] pairs in insertion order.
15 minJavaScript - EASY
Object.fromEntries
Implement Object.fromEntries — build an object from any iterable of [key, value] pairs, with later keys winning.
15 minJavaScript - EASY
Size
Implement a function that returns the element count of any collection — array, string, object, Map, or Set.
15 minJavaScript - EASY
Type Utilities
Implement a set of helper functions that report the primitive type of any JavaScript value.
15 minJavaScript - MEDIUM
Camel Case Keys
Implement a function that returns a new object with every key converted to camelCase, recursing into nested objects.
25 minJavaScript - MEDIUM
Class Variance Authority
Implement a simplified cva that builds class names from base styles, variant tables, and default values.
25 minJavaScript - MEDIUM
Compact II
Implement a function that returns a deep copy of an object with all falsy values stripped from nested structures.
25 minJavaScript - MEDIUM
Conforms To
Implement a function that checks whether an object satisfies a source schema of predicate validators.
25 minJavaScript - MEDIUM
Console Log History
Implement a wrapper that intercepts console.log calls and records their arguments for later inspection.
25 minJavaScript - MEDIUM
Count By
Implement a function that tallies how many array elements map to each key produced by an iteratee.
25 minJavaScript - MEDIUM
Deep Clone
PREMIUMImplement a function that recursively clones a JSON-serializable value without sharing references.
25 minJavaScript - MEDIUM
Deep Merge
PREMIUMImplement a function that recursively merges two objects, combining nested properties rather than overwriting them.
25 minJavaScript - MEDIUM
Deep Omit
PREMIUMImplement a function that returns a copy of a value with the given keys stripped from every nested object.
25 minJavaScript - MEDIUM
Event Emitter
Implement an EventEmitter class supporting on, off, and emit to register and trigger listeners.
25 minJavaScript - MEDIUM
Event Emitter II
PREMIUMImplement an event emitter where subscribe returns a handle whose release method removes that listener.
25 minJavaScript - MEDIUM
Get
PREMIUMImplement a function that safely reads a nested object path and returns a default when any segment is missing.
25 minJavaScript - MEDIUM
get / set
Implement get and set — read and write a nested value by a path like 'a.b[0].c', creating missing containers on set.
25 minJavaScript - MEDIUM
Group By
Implement a function that buckets array elements into an object keyed by the value an iteratee returns for each.
25 minJavaScript - MEDIUM
instanceof
PREMIUMImplement an instanceof check — walk the prototype chain to see whether a constructor's prototype appears in it.
40 minJavaScript - MEDIUM
invert
Implement invert and invertBy — swap an object's keys and values, grouping collisions with invertBy.
25 minJavaScript - MEDIUM
Is Empty
Implement a function that decides whether a value is empty across arrays, strings, objects, Maps, Sets, and primitives.
20 minJavaScript - MEDIUM
jQuery Class Manipulation
Implement chainable addClass, removeClass, toggleClass, and hasClass helpers on a DOM element wrapper.
25 minJavaScript - MEDIUM
localStorage With Expiry
Implement a localStorage wrapper that stores values with a TTL and returns null once an entry has expired.
25 minJavaScript - MEDIUM
mapKeys / mapValues
Implement mapKeys and mapValues — transform an object's keys or values while preserving its structure.
25 minJavaScript - MEDIUM
Mini Object-relational Mapper
Build a simplified in-memory ORM with model delegates that expose basic CRUD operations.
25 minJavaScript - MEDIUM
Object.assign
Implement Object.assign — copy own enumerable string and symbol properties from sources onto a target, skipping nullish.
25 minJavaScript - MEDIUM
Object.create
PREMIUMImplement Object.create — make a new object with a given prototype and optional property descriptors.
40 minJavaScript - MEDIUM
pick / omit
Implement pick, omit, pickBy, and omitBy — build a subset of an object by a key list or by a predicate.
25 minJavaScript - MEDIUM
Squash Object
Implement a function that flattens a nested object into a single-level object using dot-delimited keys.
25 minJavaScript - MEDIUM
Test Runner
Implement a minimal test runner that registers cases, runs each one, and reports pass and fail counts.
25 minJavaScript - MEDIUM
Turtle
Build a Turtle class that tracks position and heading as you issue movement and turn commands on a 2D plane.
25 minJavaScript - MEDIUM
Type Utilities II
Implement helpers that accurately identify non-primitive JavaScript values such as arrays, plain objects, dates, and maps.
25 minJavaScript - MEDIUM
Unsquash Object
Implement a function that rebuilds a nested object from a flat map of dot-delimited keys.
25 minJavaScript - HARD
Backbone Model
PREMIUMImplement a Backbone-style Model class that stores attributes and emits change events per key.
40 minJavaScript - HARD
Deep Clone II
PREMIUMImplement a deep clone that copies nested values and correctly handles circular references using a visited map.
40 minJavaScript - HARD
Deep Equal
PREMIUMImplement a function that determines whether two values are structurally equal across nested objects and arrays.
40 minJavaScript - HARD
Mini Object-relational Mapper III
PREMIUMBuild a simplified in-memory ORM with field selection and eagerly included related records.
40 minJavaScript - HARD
structuredClone
PREMIUMImplement structuredClone — deep-clone a value including Map, Set, Date, RegExp, typed arrays, and circular references.
40 minJavaScript - HARD
Styled Text Ranges IV
PREMIUMImplement a function that patches shallow style objects over a text range without clobbering unrelated keys.
40 minJavaScript