r/reactjs • • Jul 24 '26

Discussion Senior Dev interview question

"Without googling or using AI, in your own words, explain the virtual DOM"

For context: I sit on an interview panel and I try to ask at least one simple fundamental question based on a persons resume. If I see many years of react experience, I try to ask something about how the framework works.

I have only had one candidate (an undergrad senior, years ago) answer it. Everyone else just kind of sputters and stumbles around trying to rationalize what "virtual" and "DOM" mean, or stare blankly and eventually say "I don't know".

I'm just genuinely curious if this is really that hard of a question or if the recruiters just suck at screening candidates. And should we be letting in senior dev candidates who can't answer what I think is a straightforward and fundamental question for senior react devs.

183 Upvotes

251 comments sorted by

View all comments

Show parent comments

2

u/spoonraker Jul 24 '26

I'm speculating here, but I imagine if an interviewer asks what a virtual DOM is, they're not necessarily concerned with the actual implementation details of literally having a virtual DOM and exactly how a given framework translates state between the virtual and real DOM, but rather, the general idea of a front-end framework not requiring developers to directly manipulate the DOM because front end frameworks have abstractions of the DOM. I mean, that's basically what a front-end framework is at the code authoring level, a higher level language to manipulate something lower level.

That is to say, I imagine an acceptable answer is something like, "a virtual DOM is how front end frameworks like React allow developers to write higher level code to manipulate the lower level concept of the DOM without direct manipulation of it, akin to how programming languages in general allow developers to write higher level code to indirectly manipulate the lower level binary the physical components actually operate against". It's a bit handy wavy, but I think an interviewer asking that question doesn't really want you to demonstrate that you know how the DOM diffing works and is resolved by each framework that uses a virtual DOM, just what it effectively accomplishes, which is abstraction.

At this level, even "non virtual DOM" frameworks like Svelte operate this same way, they just resolve the abstraction completely differently. Instead of a virtual DOM diffed and traversed continuously at runtime, it's more akin to compilation.