JavaScript Core interview questions
100 Frontend Engineering practice questions. Read what a strong answer covers, then practise it out loud against the clock.
Practise JavaScript Core questionsBeginner
- == vs === in JavaScript
- 0.1 + 0.2 does not equal 0.3
- A function accidentally changes the original array
- A loop with setTimeout prints the same value every time
- A variable is unexpectedly undefined or throws before use
- Arrow functions vs regular functions
- Checking whether a value is an array
- Classes in JavaScript
- Closures in JavaScript
- Converting strings to numbers safely
- Destructuring, spread and rest
- Error handling with try/catch
- ES modules: import and export
- Functions as first-class values
- Hoisting in JavaScript
- JavaScript data types
- JSON.parse and JSON.stringify
- Making a deep copy of an object
- map, filter and reduce
- null vs undefined
- Optional chaining and nullish coalescing
- Prototypes and prototypal inheritance
- Reference vs value in JavaScript
- Removing duplicates from an array
- Safely accessing deeply nested data
- Scope in JavaScript
- Sorting numbers gives the wrong order
- Strict mode in JavaScript
- Template literals
- The this keyword in JavaScript
- this is undefined inside a callback
- Truthy and falsy values
- Two identical objects are not equal
- var, let and const in JavaScript
Intermediate
- A date shows the wrong day for some users
- A shared object causes data to leak between users of a function
- A subclass constructor throws an error about this
- An accidental global variable causes strange bugs
- Calculating money totals accurately
- call, apply and bind
- CommonJS vs ES modules
- Currying and partial application
- Debounce vs throttle
- Error types and custom errors
- Garbage collection and memory leaks in JavaScript
- Getters, setters and property descriptors
- Grouping array items by a property
- How property lookup works on the prototype chain
- Immutability patterns in JavaScript
- Implementing a deep equality check
- Implementing a simple event emitter
- Implementing debounce for a search box
- Implementing memoization for an expensive function
- Iterators and generators
- JSON.stringify fails with a circular structure error
- Large IDs lose precision in JavaScript
- Map, Set, WeakMap and WeakSet
- Memory keeps growing in a single-page app
- Object.freeze vs const
- Processing a large array is slow
- Proxy and Reflect
- Pure functions and side effects
- Refactoring a long, complex function
- Safely parsing JSON from untrusted sources
- Sorting objects by multiple fields
- Symbols in JavaScript
- Type coercion rules in JavaScript
Experienced
- A hot function suddenly becomes slow
- A prototype pollution vulnerability is reported in your code
- A third-party script breaks your app by modifying built-ins
- Caching results keyed by objects without leaking memory
- Choosing an approach for precise financial calculations
- Code uses eval to evaluate user-provided expressions
- Deep recursion crashes with a stack overflow
- Designing a robust utility library API
- Designing a small observable value utility
- Efficient immutable updates of large nested state
- Execution contexts and the call stack
- Functional programming patterns at scale
- Generating unique IDs reliably in the browser
- Handling millions of small objects in memory
- How closures and scopes affect memory
- How JavaScript engines optimise code
- How JavaScript evolves: the TC39 process
- Implementing a deep clone that handles edge cases
- Implementing an LRU cache in JavaScript
- Investigating a memory leak with heap snapshots
- Migrating a codebase from CommonJS to ES modules
- Module resolution and tree shaking
- Number and date formatting is wrong for international users
- Parsing a huge JSON response freezes the page
- Prototype pollution
- Realms, structured cloning and cross-context data
- Recursion limits and stack overflow in JavaScript
- Refactoring class-heavy code toward simpler functions
- The Intl APIs for internationalisation
- Typed arrays and ArrayBuffer
- Unexpected behaviour from sparse arrays
- WeakRef and FinalizationRegistry
- Writing a polyfill for a missing feature