← All videos

Engineering video

21:47 · 26 March 2025

5 HARD JavaScript interview questions for 2025

Chapters 5 sections

  1. 0:00Introduction and Tail Recursion
  2. 3:47Garbage Collection and Memory Management
  3. 9:16Generator Functions
  4. 14:00Array Sort Time Complexity

Key concepts in this video:

1. Tail Recursion and the Event Loop

Tail recursion occurs when the last call in a recursive function is a call to itself, allowing compilers to optimize stack memory usage from O(N) to O(1) by reusing a single stack reference, though engine support is limited primarily to Safari.

Watch section from 0:19 →

2. Garbage Collection and Memory Management

JavaScript runtimes use internal garbage collection algorithms to periodically free unreferenced heap memory, but heavy usage of closures can retain lexical scope variables in memory and lead to high RAM consumption.

Watch section from 3:47 →

3. Generator Functions and Iterators

Generator functions use the yield keyword to return different results across multiple calls and create iterators, providing the underlying mechanism for async/await syntax sugar and managing internal states like an infinite counter.

Watch section from 9:16 →

4. Array Sort Time Complexity

JavaScript engines typically implement Timsort for array.sort, yielding an average and worst-case time complexity of O(N log N) and a best-case time complexity of O(N).

Watch section from 14:00 →

5. Object Proxies and Reactive State

Object proxies wrap target objects and intercept operations via custom handlers, allowing developers to implement features like custom state management and reactive components with re-renders.

Watch section from 16:00 →

6. Signals in JavaScript

Signals are an upcoming feature in early consideration that aim to natively bring reactive variables and the observer pattern to vanilla JavaScript.

Watch section from 20:00 →

Transcript

Hi folks, I'm Russia, I'm the senior Dev and today together with, we're going to go to some of the highest and weirdest JavaScript interview questions that even senior devs can't answer. First question, can you explain tail recursion in the context of the event loop? And how is it useful in JavaScript? Okay, so let's talk about tail recursion. So, basically, tail recursion, it's when the last call in a recursive function, it's a call to itself.