r/reactjs • u/m6io • 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.
7
u/ReactTVOfficial Jul 24 '26
The more experienced you are, the more you deal with nuance.
In a interview that asks that question of a senior dev, they are going to assume there is a "gotcha" underlying this question.
It's not that it's a bad question, but not everyone is prepared with a straightforward answer.
It's like asking "what is flour" to a baker. You could answer it a hundred different ways.
36
u/monkeybrainz_ Jul 24 '26
It's a basic question that any senior engineer who has worked with React should know.
3
u/cherylswoopz Jul 24 '26
Happy to say that my answer without googling wpuld have been at least okay in an interview.
I knew the concepts and ideas pretty well but just didn’t quite have all the words in my head.
Got an interview Monday so thanks for the reminder to bone up on fundamentals
3
u/Disastrous_Bass_7090 Jul 24 '26
Ohh i would've answered this question straight up for an hour. As I implemented virtual dom from scratch, I would've loved to talk about it
3
u/cazzer548 Jul 24 '26
I like this question, although it has the risk someone brain farts on the term and freezes. Maybe there’s a more abstract “how does react work” question, similar to the age old “walk me through a web request” question.
I like this question because you’re customizing it to their background, and you’re assessing their understanding of a self-professed skill. If someone doesn’t know how a tool like React works they will inevitably misuse it, and if they don’t care to learn how one of their tools works the same could be true for their other tools.
207
u/BobSacamano47 Jul 24 '26 edited Jul 24 '26
One other thing, and for context I interview people often. Sometimes I find that senior devs who write a lot of code know the concepts, but sometimes get stuck on the naming. Like they may know the idea of the virtual DOM, but the phrase "virtual DOM" doesn't instantly click in their head. So sometimes I'll give an example or start describing it and they'll jump in with other examples or facts. If you see they aren't getting it though, jump to something else. They may be more skilled in some other area. A senior engineer doesn't have to know everything about everything, but they should know a lot about something. There are a lot of fakers out there too though.
2
u/Glass-Combination-69 Jul 26 '26
I mean I’m a senior dev and this is a super basic question to me. Zucky boi and react made it famous, and a lot of devs use react so would be crazy not to understand how it works.
A more telling interview question would be to explain the shadow dom. That’ll get em.
172
u/vozome Jul 24 '26
To play devil’s advocate, when react was new this was a key selling point and the explanation of its alleged superior performance. Now, I would say it’s an implementation detail, among React competitors some use a virtual DOM and some don’t. Maybe one day React will move away from the virtual DOM without changing its interface. I don’t think it matters that much
146
u/BrightEchidna Jul 24 '26
Senior react dev here - and while I can take a stab at the answer, I don't feel 100% confident that I really understand it. So, despite leading technical teams, building successful products, and now running my own startup, I would fail your interview.
Now - can you explain to me - what practical advantage would being able to answer this question well give me? I agree, it's generally 'good' to understand the tools you use, but how would it help me write better software in the 99% of cases where what I have to do is well supported by standard use of the framework?
61
u/brett9897 Jul 24 '26
As someone with hiring experience, I learned even seniors don't know the technical terms even if they know the concept. You would be surprised how few people could answer "what is a closure?" But if I provided them a simple task to do that required using a closure 90% of the people that couldn't answer "what is a closure?" could properly solve the task.
A second thing, is knowing what the virtual dom is and how it works essential for producing senior level React code? If it isn't, then it is just a dick measuring question and useless in determining who would be good at the job. If you can provide an example during the interview of when knowing what the virtual dom is will effect a coding decision in react that might be more helpful in assessing whether or not they are a strong candidate for the job.
Someone interviewing to be a developer on the team that makes React should really know what the virtual dom is, how it generates change sets through diffs, and how it applies those changes to the real dom, but I don't know if you need to now that to create a CRUD UI in React.
91
u/someGuyyya Jul 24 '26 edited Jul 24 '26
To be honest, it is a trivia question since you can design frontend systems using react without knowing that super specific detail unless you luckily ran into it in the wild, like the senior undergrad student you mentioned.
I only memorized that trivia fact because everyone likes to ask it in interviews for senior positions.
31
u/goodeyedeer Jul 24 '26
Because it solves a fundamental problem so well they barely have to think about it anymore.
20
u/chillermane Jul 24 '26
It’s a gimmick question and anyone who is screening with question is a midwit
I’ve hired a bunch of people and it annoys me so much that people who think this is a good interview question are making decisions that impact people’s lives
9
u/writetehcodez Jul 24 '26
After 18 years of interviewing candidates using various interviewing styles and techniques I can confidently two things:
I’ve had plenty of hires that didn’t work out for one reason or another, but the reason was never a lack of knowledge, skill, or capability.
Many of my better hires have transitioned and applied skills and knowledge from other languages and stacks to what they’re currently working on. One of the best react devs I’ve hired had only vanilla html, css, and javascript experience when I hired him.
7
u/azhder Jul 24 '26
React is not a framework. I would start with that.
Virtual DOM is an in-JS-memory representation of the DOM tree as it is or it should be, for the matter of optimization since DOM operations are more expensive.
Now, my job as an interviewer isn’t to fail those that don’t answer the above, but those that don’t try or aren’t curious or don’t figure it out, especially if I give them hints and even the above definition.
Over a decade ago, I had a boss that asked me a similar question to you. He said “don’t they teach you at school about big O notation? No one tried to answer that question. Should I remove it?”
My reply was that he should keep the question and hire the first one that attempts to answer it. You see, they teach algorithm complexity at school in a handwavey passerby manner, so students learn it by heart for a test then promptly forget it.
6
u/Nikurou Jul 24 '26
4 YOE. I'm honestly just the type of dev to do my work and not look into how things work beyond when I'm first learning. Once I have enough information to work on tasks, I just get to work. I typically find such information comes to me eventually through tickets that I have to resolve while doing actual work in a learn as you go approach.
Of course, it's definitely something I've looked up the official definition for at one point, maybe around when I was learning React, but off the top of my head, I might not be able to articulate a coherent answer. Perhaps this is why the Senior Undergrad was able to answer best?
I think at best I would say the virtual dom is where React can batch multiple state changes together to the actual DOM so you don't trigger a re-render for every setState. Maybe id also say it allows React to only update what changed in the DOM. (Is that right?)
Or maybe I'd entirely fumble and shut down! I might actually know these things, but in an interview, you might have to dig it out. Perhaps if someone is struggling, you can break down the question into questions related to the Virtual DOM instead of "what is the virtual dom".
Like if the person fails to explain virtual DOM, maybe ask them "when you have multiple setStates in the same function, explain to me how react renders these changes to the UI". Perhaps if they're able to answer, it's clear then that they understand the underlying concepts behind virtual DOM, but just fumbled.
It might also give them a chance to combo into their answers by explaining how setState is async and how React batches setStates and etc.
11
u/octocode Jul 24 '26
we’ve seen a massive influx of fraudulent interviewees who know absolutely zero about the topics/technologies they have listed on their resume. some of them were clearly running AI on their second monitors during pairing.
1
u/THCRaven Jul 24 '26
React is a library
1
u/stuffmixmcgee Jul 28 '26
In all my years writing frontend code and React, I have had zero need or care to understand this. React does not, in the slightest bit, require you to, and if it did, it would really be a leaky abstraction. Knowing what it is just doesn’t help you build react.
There are loads of good react questions you can ask. You could ask about what context is, and about its performance issues. You could ask about different state management libraries and approaches (redux/zustand/…). You could ask about controlled and uncontrolled components. You could ask how to build a custom uncontrolled component that works with a standard HTML form submit (hidden input component). What suspense is, the risks of using multiple suspense queries in components (waterfalls). You could ask CSS questions eg how do you build a UI of multiple separate tables which all have aligned columns? (Subgrid).
Virtual DOM, as others have said, is truly just an implementation detail. “We render to a separate dom, diff and then make minimal changes to update the browser dom” - this knowledge has literally never helped me.
1
u/Expensive-Wheel-2773 Jul 30 '26
Honestly, there’s just so much to remember, I imagine a lot of people learned what the virtual DOM is, then forgot because they don’t have to think about it anymore. If I don’t actively work with something every day, I’ll forget all the details a year later
And for newcomers, is learning about the DOM really that necessary for writing working front-end code? In my opinion, no. I don’t even think about the DOM when I write code and I’m a senior
3
u/Used_Lobster4172 Jul 24 '26
I have asked and answered that question a bunch of times. It is pretty basic for a senior.
3
u/Vincent_CWS Jul 24 '26 edited Jul 24 '26
what is virtual dom, it is fiber now, react team doesn't like virtual dom, because it is just plain js object store the hook information and the type, nothing special. react will form the fiber with react element and to determine the fiber can be high optimze or low level bailout.
Dan Abramov said
I wish we could retire the term “virtual DOM”. It made sense in 2013 because otherwise people assumed React creates DOM nodes on every render. But people rarely assume this today. “Virtual DOM” sounds like a workaround for some DOM issue. But that’s not what React is.React is “value UI”. Its core principle is that UI is a value, just like a string or an array. You can keep it in a variable, pass it around, use JavaScript control flow with it, and so on. That expressiveness is the point — not some diffing to avoid applying changes to the DOM.It doesn’t even always represent the DOM, for example
<Message recipientId={10} />is not DOM. Conceptually it represents lazy function calls:Message.bind(null, { recipientId: 10 })*.*Is "Virtual DOM" the Right Phrase?
│ We used to call the collection of JavaScript objects in React that are structured like the DOM the "Virtual DOM". But React doesn't
│ like that term now because you can target other things like native iOS and Android apps (React Native) to render to.
│
│ In fact, there are multiple trees that React deals with, a tree of React Elements (JS objects) that your function components return
│ and a Fiber tree (also JS objects) that React Elements are converted into and used to store state among other things. While I usually
│ refer to these two trees more specifically, for this post I'll use the long-standing colloquial term "Virtual DOM" because it's
│ useful in keeping track of how RSCs work.
3
u/patmacs Jul 24 '26
The dom (Document Object Model) contains all of the nested html elements <body>, <div>, <nav>, <article>, ect. that make up a webpage. The browser has to calculate the complicated series of nested elements (as their class and css properties) in order to render the webpage (DOM) to the screen. This is not generally a lot of compute, but if your site is constantly changing widths and heights, then the browser has to painfully recalculate everything over and over and over again. Introducing - The virtual DOM is a method of having the browser keep track of the nesting/classes of every element the site - and hold onto it in memory (super fast), instead of having to redraw the entire painting - It can recognize that ONLY these specific parts of the picture that have changed.
3
u/CatTurdTamer Jul 24 '26
My perspective on this is that at least, a senior should be able to give a high level explanation about the Virtual DOM, nothing too detailed or too technical. Just enough understanding so that whoever is hiring can have some assurance that dev knows the consequences of every hook/line of react code that he/she (or AI) is writing.
5
u/BobSacamano47 Jul 24 '26
Honestly, you're just getting bad candidates. Good recruiters are worth it in my experience. I wouldn't expect everyone to have the perfect answer, but a senior dev with many years of react experience should be able to say a decent amount.
2
u/GForce1975 Jul 24 '26
I wrote an app years ago using react in electron and I literally just had to go ask Google to remember electron. I remember virtual dom but Im pretty sure it's just the react version of the Dom that helps keep the real Dom immutable.
2
u/kidshibuya Jul 24 '26
I thought oh that is super simple, but then reading the responses here I was thinking oh, i must not understand it. But after googling... yeah, its as basic as I thought.
But I don't directly ask that kind of question in my interviews. I couldn't care less what terms devs can describe, I only care about what they can do. So ill ask questions where some consideration of the vdom would be needed, like mouth blog building me an infinite scroll, and i'll listen for techniques that take advantage of vdom (or better yet cull nuneeded things before the vdom).
2
u/the_real_some_guy Jul 24 '26
I used to teach some React classes and I would go over it in the first hour or so. “What is React and why do we need it?” feels pretty fundamental to me. It would be a bit like teaching hammers without talking about nails.
But, no I don’t expect most devs to be able to explain it… or why we don’t really need it anymore.
2
u/ScientificBeastMode Jul 24 '26
I mean, I’m an outlier because I built my own virtual DOM for fun as a side project.
The funny thing is the VDOM is not really a VDOM anymore in React, ever since the “fibers” concept was implemented years ago.
It’s now more like a linked list of tasks to perform DOM operations, but still has a tree structure. The main thing is that it doesn’t just eagerly walk the tree and apply changes to the DOM. Instead, each component produces a list of operations to perform, and there is an interpreter that reads that list and applies the changes in batches, allowing async operations to run between batches to avoid noticeable blocking. It also supports pausing and resuming the rendering of entire subtrees.
The version I built was way simpler than that, but a fun project nonetheless.
2
u/yikes_42069 Jul 24 '26 edited Jul 24 '26
Frameworks are a dime a dozen. I care more about versatility than if someone knows a framework's implementation cover-to-cover. I want to know if what the dev learned on their stack is something they can reapply and if they're smart enough to go learn those details when they need them. Aptitude is so much more meaningful than abstraction trivia. But chances of needing to know much about vdom beyond the thing that gives me headaches are slim.
2
u/CoolJoey99 Jul 24 '26
I'm not even a pure React guy and I am confident I can explain it to a decent level. For a react role someone is of course going to ask " Why React? " and having some understanding of virtual dom is a fundamental part of it.
2
u/otaviomad Jul 24 '26
i’m seeing a lot of justifications here in the comments. this is something i knew about react from the start. i guess this filters out uncurious people. i dont like using systems i dont understand
2
u/lucidmodules Jul 24 '26
Just ask the candidate to explain when to useEffect and when to not use it. That's more related to the job they are going to do.
2
u/Low-Sample9381 Jul 24 '26
Tbh I don't think think this is a good question to filter out a senior dev. A good Dev can overcome this knowledge gap in 60 minutes max.
To me what makes a senior is the ability to face unexplored territory, handle complicated junior Devs, explain complex technicalities to non coders, help juniors grow, make technical analysis, Ecc. You can't teach these skills in not even a month each.
Maybe we have a different definition of seniority as a Dev, but in my book having many years of experience doesn't make you a senior dev necessarily.
If the candidate knows what the virtual Dom is might be a sign of curiosity or rigorous docs reading, both good signs, but it is very likely that a Dev can output perfect react code without even knowing how the virtual Dom works.
2
u/vasind-5012 Jul 24 '26
not that hard a question tbh, but i get why people blank, it's stuff you use daily without ever saying it out loud
my version: lightweight JS object repping what the UI should look like. state changes → react builds a new one, diffs it against the old, figures out the minimal real DOM changes needed, applies just those. point is direct DOM ops are expensive so react batches/minimizes them
freezing's probably more nerves than lack of knowledge. wouldn't fail someone off one blank stare, would follow up with "why does react even need this" to see if it's actually there under pressure
2
u/link2twenty Jul 24 '26
I have a junior member of staff that I'm training up, giving them a basic breakdown of the web from CERN to modern day was one of the first one to one sessions we had, which included a brief look at the Virtual DOM and why it took off.
2
u/corgiplex Jul 24 '26
I learned react ages ago when doing FE... definitely know what this is 🤷♂️ crux of react how it works.. pretty important
2
u/strongdoctor Jul 24 '26
For a senior frontend dev yeah, i agree, it's a disqualifier. If they can't even vaguely describe it, that's game over
2
u/Metabolical Jul 24 '26
I'll just blurt out it's a simulation of the browser's document object model so react can finish composing your DOM, diff it with the actual DOM, and then make selective edits so you can minimize re-rendering and have sexy slickery apps that don't flicker. I think there's a little more to it, like it keeps thing performant because rendering the DOM is slow. How'd I do?
But the potential problem with your question is you can use React pretty effectively without knowing that, so from an interviewing perspective, I tend to consider it a "trivia question" where you either know or you don't. Answering it accurately tends to be a positive sign but not knowing it could just be a random gap in their knowledge. If they said they were an expert in optimizing React performance, I would expect this knowledge 100%. In general, I try to avoid trivia questions.
BTW, I would only consider myself OK at React, but I happen to think I know this answer. But I learned React in 2018, when it was part of the base explanation.
2
u/2580374 Jul 24 '26
I can't believe people are saying they can't answer this. I've been asked this question like 4 times in interviews and it is on every list of "react interview questions"
2
u/mr_brobot__ Jul 25 '26
It’s a lightweight representation of the DOM that react uses in the reconciliation process to produce a diff of a render cycle compared to the previous render cycle. It then uses that diff to commit updates to the actual DOM.
It’s used as a performance enhancement, because producing a new DOM tree and comparing to the current actual DOM would be way too expensive.
2
u/dxsquared Jul 25 '26
I learned what it was before I even looked at react code. If someone wasn't able to explain it, I wouldn't write them off yet, but they should be able to explain foundational concepts like they know the back of their hand.
2
u/Routine-Arm-8803 Jul 25 '26
“Do you mean DOOM game franchise?”
2
u/muf_codes Jul 25 '26
Wait what? Do people actually don't know what a virtual DOM is?
2
u/MonkAndCanatella Jul 25 '26
lol that’s insane. But having sat in the interviewers seat a few times it’s fucking insane how poorly some people do
3
u/gHHqdm5a4UySnUFM Jul 24 '26
I think this is a good question and it is relevant to the job too because devs should understand that direct DOM manipulation can be expensive. Maybe I’m biased but I don’t think it’s a hard question, it’s a fundamental building block of React and something you’d cover during the introduction.
4
u/soundisloud Jul 24 '26
That's a great question.
It's going to let knowledgable people shine.
It's going to inspire people who don't know the answer to go look it up and understand it better.
It's not a 3 hour take home or "gotcha" question.
It's about the backbone of what we work with every day.
2
u/GhostDog76 Jul 24 '26
I don’t think this question says much about whether someone is a senior developer.
As a senior, I don’t really think about things like the Virtual DOM anymore. You naturally follow good practices because you’ve already internalized them through experience.
I’d be more interested in how they understand business requirements, how they turn specs into maintainable code, and whether they can work with minimal supervision. I’d also look at their commercial mindset like do they think about business value? How about practical trade-offs instead of just writing code?
And honestly, you can’t ignore AI anymore. I’d rather ask how they use AI in their daily workflow. A good senior developer knows how to use it to deliver better results faster while still reviewing and validating the output.
1
u/Operation_Fluffy Jul 24 '26
I went back for a masters a couple years ago and for one class we did a group project. It was shocking to me that nobody seemed to know how Oauth worked. I basically had to write the whole project myself.
As for the virtual DOM I’ll be the first to admit that even though I’ve written a fair bit of React over the years, I’ve never need to know or care how it works. I mean, I could probably make an educated guess but that’s all it would be.
1
u/PresentationBorn6564 Jul 24 '26
Hi. Senior engineer here.
If we're being honest, your question is flawed. There's no such thing as "the" virtual DOM — that's akin to saying "the" ORM.
A virtual DOM is a pattern in which an in-memory representation of a DOM subtree is regarded as the source of truth for a node on the browser DOM, facilitating declarative DOM operations. There are numerous unique implementations.
I can start Tuesday.
1
u/isospeedrix Jul 24 '26
Staff FE here, while I know this answer and I get asked it a lot I’d never ask it myself. Dumb trivia question that only tests memorization. Same with questions like What’s a closure and Whats event loop that people have a hard on for. Not a fan.
1
u/rocket1420 Jul 24 '26 edited Jul 24 '26
Do you want someone who can recite mostly irrelevant facts from a book, or someone who can demonstrate useful job skills? I know what a lot of things are, but I'm terrible at defining them.
1
u/kyledouglas521 Jul 24 '26
My honest answer to this is that I learned the term, along with what it meant, and then it never came up again in the 4 years I’ve been working with React, so my brain discarded the information.
1
u/1ib3r7yr3igns Jul 24 '26
It's just a piece of information that a senior dev doesn't need to keep on the top of his mind all the time. When was the last time on the job you needed to know the answer to that question?
Last time for me would have been elbow deep in some obscure front end bug that was caused by a browser update. I relearned what it was and how it works, fixed the bug, and then promptly forgot it when I didn't use it for the next 2 years.
1
u/didnt_knew Jul 24 '26
I think a fun way of asking this question is to instead ask about pagination. You can do it per page on click and deep dive that (api setup etc), and then get them into infinite scroll. From there, you can have them talk about writing to dom/virtual dom, and explaining tradeoffs and optimizations. It gets a nice level of where they’re at
1
u/Suitable_Speaker2165 Jul 24 '26
I think this is definitely a question that will skew you towards very terminology-heavy devs or someone who has been around a long enough time to have actually dealt with on their own and not have had it delegated to a framework. I'd say that would probably be 20-30% of devs at this point.
If you're building some plug-in for some UI framework then maybe this is important but if you're primarily a consumer of React for example, I wouldn't say this is a useful question. You're just wasting your time by not asking something that is more directly relevant.
1
u/pakman_198 Jul 24 '26
If I was on an interview, my response would be: Picture the DOM as a folder with files, and the Virtual DOM as an exact copy of that folder. If you make a change on a file, due to a process called reconciliation the Virtual DOM can see what file was changed and update it accordingly instead of having to generate a new copy of the folder to have the lates changes.
I think this oversimplifies the concept but the analogy helps to explain the concept.
1
u/zhou111 Jul 24 '26
It's a basic trivia question but I think a frontend engineer should be able to answer it. If the candidate doesn't specialize in frontend then I wouldn't blame them for not knowing.
1
u/wreeecks Jul 24 '26
This should be one of the interview question.
AI is acceptable as long as the candidate have a strong fundamentals.
On second thought, this information is good to know because there's nothing you can do with it. It won't affect any coding or app performance if you know this info.
The only significant info related to virtual dom is the reconciliation, understanding keys and nodes kinda helps in development.
1
u/nath1as I ❤️ hooks! 😈 Jul 24 '26
How did knowing react implementation help you in your day to day job? I knew the answer to this before I had any experience with development, I don't think its that great of a question.
1
u/HungryCaterpillers Jul 24 '26
That question only tests trivia. You can be a good react dev without ever knowing what the virtual dom is and how it works.
1
u/azangru Jul 24 '26
Oh, you are an interviewer in this situation?
Then how do you rationalise the purpose of this question? What is the point of asking it? What does it tell you about the candidate, and about what he can or cannot do?
1
u/Fitzi92 Jul 24 '26
I consider myself a senior react dev with over 5 years of experience writing react almost daily. I couldn't confidently answer that question. I know the rough concept/idea, but honestly, for getting shit done in react, this is absolutely unnecessary to know. This is an internal detail, something the react dev team choose and when they choose to abandon the virtual dom completely in the next version, the way you and I work will not be affected at all (unless you do hacky stuff with react). I see no real benefit in knowing all the internal details of a library and I would probably never reject a candidate based on that. I'd much rather ask questions about the things that matter on a daily basis and that people often get wrong, like: what hooks react provides, when they are appropriate to use (and when they aren't; especially useEffect), how to avoid unnecessary rerenders or infinite loops, when does a global store make sense, when local state, when context, etc. I argue having a solid understanding of these things is far more valuable than knowing the internals.
1
u/GoodishCoder Jul 24 '26
I personally try to avoid trivia / vocab questions. What I have found is even if the candidate knows the material, it's some of the first things they forget when they're nervous. If they don't know the material, it is generally some of the easiest stuff in the world to teach when it matters.
I try to stick to things on their resume and focus on how they think because most people can still talk about the things on their resume even when they're super nervous.
1
u/jeffiql Jul 24 '26
It’s not a bad question but it’s also not particularly good. I recommend asking the question, reassuring the candidate that they don’t need to have the answer memorized. If they know, great . If not, define it for them briefly. The follow-up question of “why is a virtual DOM useful?” Is probably way higher-signal. If the candidate can speak to the various benefits afforded by vDOM then that’s probably a good indicator of their technical depth.
1
u/Lunateeck Jul 24 '26
This is the type of question that someone with a very theoretical and academic mindset would be able to answer well; whereas someone more hands on would struggle. What kind of professional are you looking for? Yes, I know you probably want both… but then I hope you have enough budget to hire this person , because they are the type that would usually work for FAANGs…
1
u/mtimmermans Jul 24 '26
I think it's actually a pretty hard question, because:
It took me a minute to formulate an answer in my head, because I was trying to decide what part of the process the words probably actually referred to. What I came up with was "It's the data structure that remembers what a react component renders, so that it can be compared against what it produces when it's rendered the next time."
There certainly is such a data structure, but is that exactly the one that gets the "virtual DOM" label? Not sure.
1
u/gemini88mill Jul 24 '26
I've worked with react for 5 years and I don't think I could explain this accurately. I think a better question would be related to the react lifecycle
1
u/lucksp Jul 24 '26
I’ve been working w react since 2018 and virtual dom has never come up in conversation.
1
u/BarneyChampaign Jul 24 '26
I've done this for 15 years and I still second guessed myself, having to look up and refresh on shadow vs virtual dom details.
Does your product rely on custom tooling that requires knowledge of how to access and manipulate the vdom directly?
Otherwise, if it's just a senior React/Vue/whatever role, then it's like asking a digital artist if they know how graphite is refined. What does that knowledge bring to the table in their day-to-day?
If you just want to ask it to see how they handle that type of question, that's one thing, but if one of my seniors was interviewing someone with me and asked that, and afterwards discounted an otherwise strong candidate due to not knowing the answer, I'd absolutely challenge them to justify their stance.
1
u/null_pointer05 Jul 24 '26
I got that question in an interview six years ago, surprised it's still popular. It wasn't even a senior position I was interviewing for, more midlevel. I was trying to get back into software engineering after being a SAHM and just having a little part-time non-tech job for over 10 years, so the odds were pretty much against me. I was able to answer it thoroughly because I studied my ass off for interviews. I researched all the common questions like "What is the virtual DOM?", "What is a closure?", "Explain 'this' in Javascript" and studied the answers. Got the job, so it was worth it.
1
u/Sherbet-Famous Jul 24 '26
It's not necessarily a "hard" question but it is obscure. Who cares exactly about what the vdom is or how it works as a guy writing FE code
1
u/Notoday44 Jul 24 '26
If only one person has ever correctly answered your question, maybe it’s a bad question.
1
u/madfcat Jul 24 '26
It's actually just shows how curious the candidate is about React. Some devs don't even need it. But the way they answer will show the curiosity in the development in general.
1
u/roundabout-design Jul 24 '26
This is one of the side-effects of the entire web industry becoming frame-work based. People understand their framework. They often don't understand what the framework is actually doing.
But maybe that's OK. Do they really need to know that? I dunno.
I'm not sure how technical my answer would be either, now that I think about it. I'd probably say something like "It's essentially JS-based copy of the DOM that can compared to a previous JS-based copy of the DOM and based on comparing the differences, it can then update only what is necessary to be updated in the actual DOM"
1
u/augburto Jul 24 '26
IMO this is a great and valid question. I guess one thing I’d ask is what other web fundamentals you’d expect a senior to know; one thing to be mindful of is React is an abstraction and framework so developers don’t have to know what the virtual dom is.
It really depends what you are trying to assess in the interview. For a senior react dev I think it makes sense. For a generalist frontend dev, it’d be a note but nothing that necessarily swayed my decision
1
u/Tontonsb Jul 24 '26
Many highly rated answers already discard this question as crap, but I'd just like to add that whenever you start to feel like this
You should start to rethink whether it wasn't you all along who was asking the wrong question from the wrong assumptions. Maybe all those people are qualified and successful devs and thus such a professional would not need to know anything about virtual dom?
1
u/bullcityblue312 Jul 24 '26
6 yr full stack dev who also interviews people
I think this is a terrible question. And I've been asked it in interviews too. This is something I would've known in school, but not even thought about since then.
Do you think about the virtual DOM on a daily basis? Is knowing about it relevant to your daily work?
Surely there are more relevant questions you could ask. Why not bring up a ticket and pair up and see how the person is to work with? That'll tell you more than react trivia
1
u/SixStringDream Jul 24 '26
What you really want to know is if you can work with someone. Job interviews should be more about personality than gotcha questions. I will need to learn something I dont know. What you want to know is how I react to that. That tells you whether we are going to have problems. You want to know my work ethic, how I work within a team, how I respond to pressure, how my experience can help your team. These are things that are unfixable, knowing vdom is fixable. Resourcefulness trumps knowledge every day of the week.
1
u/LostArtifact198W Jul 24 '26
If they demonstrated the concepts, and didn’t know the proper noun, would you hire them?
If so, the question needs re-phrasing. What about the virtual DOM matters to you?
1
u/munkymead Jul 25 '26 edited Jul 25 '26
To be fair I've been using react since 2013, before all of the hooks, before redux, before frameworks like next etc. We used to have to build isomorphic apps from scratch. I know the answer to this and have answered it many times over the years. Has it ever helped me? Not really. When I'm working on building UI frameworks yeah but that's an interest of mine, it certainly doesnt pay the bills though and I can't actually remember a time when employed or freelancing I've ever used that knowledge other than when interviewing or mentoring others. Like performance wise I guess it helps to know, same with the event loop but the reality is that the people who pay you to deliver results dont actually care. If you need better performance don't use react. You could also argue that it's overkill for a lot of projects.
I feel like understanding principles, design patterns, how to structure code well, architect platforms and create solutions to problems are way more invaluable.
Everyone has a TV or monitor and can explain sizes, resolutions, refresh rates, colour profiles etc but only a handful of people will tell you how an oled screen works.
1
u/GahdDangitBobby Jul 25 '26
As a senior dev working on React applications daily, never once at my job have I heard someone use the words "virtual DOM". Just to point out exactly how unimportant that knowledge is. Like, I learned about the virtual DOM at some point but it never really was relevant to my actual implementation so I forgot. Like many other unimportant SWE concepts.
1
u/davesoft Jul 25 '26
"A DOM, as you know, is a structured document, it's got all the bits of webpage in it. A virtual DOM is a subset of that, either for reference or to make a bunch of changes before commiting them to the real DOM."
That's how I'd answer it. I'm sure there's a cleaner answer, but I'm happy to shrug and apply my assumptions.
It's unlikely, but, asking an impossible question is a good test of if the applicant is afraid or willing to ask follow up questions.
1
u/WeekRuined Jul 26 '26
Question is vague and overly technical, most people dont know the IDEAL answer and you probably didnt until you wrote the question
1
u/webbko Jul 26 '26
Uhh WebContainers?
1
u/godevcode Jul 27 '26 edited Jul 27 '26
Same as asking Leetcode questions. There are ton of people who never build an app, but spend years of nailing those questions so they can pass.
Leetcode can be used as basic screening with easy/ med coding questions.
But it’s either you can build shit or not. I don’t care if you know what’s virtual dom or not.
Why not to ask someone to do vanilla js? to make 80% senior engineers fail, and 90% college grads pass?
For me it’s always - build something, like list, calendar, modal. With some additional logic.
And questions on top from react, analytics, accessibility and a lot of other things.
So I can check
1 if some can actually code and how candidate thinks.
2 get general understanding on candidate knowledge from different spheres.
Because I usually expand coding task into conversational problem.
I also had AI cheaters - that’s a newest trend. When they use some voice capturing app and giving a ai generated response.
1
u/SatyrCode Jul 28 '26
For me the virtual DOM is basically a lightweight in‑memory representation of what the DOM should look like after a state change. Instead of touching the real DOM on every little update, React builds a tree of elements in memory, compares the new tree to the previous one (diffing), and then applies only the minimal set of changes to the actual DOM. That’s why you don’t manually call document.createElement or querySelector all the time - - you just describe UI as a function of state, and React turns that into efficient DOM updates under the hood.
1
u/Existing_Box3864 Jul 31 '26
We already know it, not just the name.
1
u/Intelligent_Fig_8948 Jul 24 '26
Lead software engineer chiming in … UI/React. Dumb gotcha question and I would never work for you.
0
u/mosdl Jul 24 '26
That would be an instant fail for any senior who has worked in React. I would also require them to explain the benefits and downsides - I found that a lot of folks will say that vdom is always faster and I will grill them on why they think that - usually they are just repeating what they have read with no real understanding of what the DOM is.
-2
u/BlackJairs Jul 24 '26
For senior? I've asked this question to Jrs and they respond accordingly.
Is the bar that low for senior developers now? Haha
-1
u/lovesrayray2018 Jul 24 '26
Its a good question, imo the difference between a good developer and a great developer is that the good developer has probably focussed more on the how and trying to cram as much syntactical knowledge as he can and the great developer has focussed more on the why and looking up the internals making his fundamental knowledge strong. yeah u can crucify me now :D
You should hear the responses i get when i ask "what does rendering mean in react", opens up a can of worms.
0
u/aldo_nova Jul 24 '26
Do you not allow google use at the company?
0
u/crice07 Jul 24 '26
Virtual DOM? Isn't that the same as a shadow dom?
0
u/danielkov Jul 24 '26
What's your goal with asking abstract, conceptual questions? Are you hiring technical writers?
0
u/Outrageous-Chip-3961 Jul 24 '26
The shadow dom? a replication of the DOM that can be used to diff against the actual DOM. That's how i'd answer it casually. Do I know the technical details off the top? No, would I look it up before an interview? Yeah probably.
-2
u/paagul Jul 24 '26
If a senior doesn’t know virtual DOM don’t hire them.
0
u/[deleted] Jul 24 '26
[deleted] — view deleted comment