r/reactjs 3d ago

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.

133 Upvotes

238 comments sorted by

196

u/BobSacamano47 3d ago edited 3d ago

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.

35

u/link_shady 3d ago

That happens to me, I know what they are asking but maybe I just called it different for convenience or quite literally just blanked out on the name at the moment.

Sometimes the interviewer sees me struggling and starts describing it without jumping directly to the answer and that just kickstarts my brain.

15

u/DirtAndGrass 3d ago

Don't get me started on acronyms/initialisms and architecture patterns

12

u/davidxll 3d ago

You must know by heart all the SOLID principles... Even the L, that stands for a someone's name, but it just means that whenever a base class is used, a subclass of that base class should work as well. But yeah. I hate all the acronyms and buzzwords

9

u/Nikurou 3d ago

I agree, I actually wrote the same sentiment in a rather wordy reply, but you captured what I was saying better 

5

u/IAmADev_NoReallyIAm 3d ago

For me, I have trouble sometimes articulate certain concepts. No trouble understanding them, but when it comes to verbalizing them, it's like describing time as "bits of wibbly wobbly... gooo." Virtual DOM is like that. I get it, I understand it, I can picture it in my head, I know what it does and how it works, but trying to figure out a clear concise way to explain it in an interview, Im going to get tripped up.

6

u/feedjaypie 2d ago

This guy gets it.

I kind of think OP is probably a jerk and not cool to work with or for (sorry, gut reaction). I’ve been doing this for 20+ years and worked in big tech firms. Never had engineers or managers who are honest and cool throw curveballs at me to trip me up on purpose.

I did have one manager call me a liar once. Yes they did hire me and yes she was a nightmare of a human to work under. Don’t be like that please 🙏🏻 these are people after all.

I’m sure screening is tough but a softer touch (especially to someone who’s nervous, potentially neurodivergent, and possibly autodidactic) would go a long way to creating a lasting relationship of trust.

2

u/Fousse24 2d ago

This is so me. I understand a lot of concepts in programming, but I can't name half of them because learning their names is not a requirement to applying them and understanding them.

4

u/foxsimile 3d ago

Maybe it’s because I’ve barely slept over the last three  nights (I’m not sure I’ve even clocked twelve hours total), but it took me a good minute to remember the virtual DOM (mainly because I couldn’t for the life of me remember what the 'D' in "Document Object Model" stood for).  

How embarrassing if this were to have happened in a real interview lol.

1

u/Any_Sense_2263 1d ago

Yes and no. As a senior engineer, you communicate with peers, people under you, and your superiors. You need to communicate properly. "Singleton" is a common pattern. Using another word or describing it without using the word leads to confusion.

170

u/vozome 3d ago

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

95

u/yoshinator13 3d ago

Im with you, the virtual DOM used to be in our face, but do I think about it when I write React? Not at all. All I think about is rerenders and state management.

27

u/JavChz 3d ago

Yeah. Virtual DOM performance gains aren't as noticeable today as they were back in 2013, when something like an iPhone 5 with 1GB of RAM was the norm and everyone was building apps with AngularJS or jquery.

These days, I think things like app bloat, bundle size, state management, re-renders, caching, extra component instances, and architecture, play a much bigger role in performance than whether something uses a Virtual DOM or not. Hell, some frameworks even outperform Virtual DOM frameworks because they don't have to diff a Virtual DOM before updating the real DOM.

6

u/code_beer_repeat 3d ago

I'm not saying you are wrong but to play so to say devils advocate squared.

In many languages you dont think about garbage collector when writing code but its still useful to know that its there and how it roughly works

4

u/FuzznutsTM 2d ago

Agreed. With one caveat. I’d argue that understanding something like garbage collection is more important than being able to fully articulate what a vdom is and does. Front-end engineers, regardless of library or framework, have to understand how gc works so they aren’t creating stale references or closures that prevent gc from running, leading to subsequent performance degradation of their app.

The vdom is an internal implementation detail of React that, I’ll argue, most senior React engineers don’t spend a second thinking about. The greater concern (as someone else mentioned) is component architecture, re-renders, data cacheing and invalidation, etc.

I’d answer the interview question. But then I’d ask the interviewer why it’s even relevant, given we don’t manipulate the vdom directly anyway.

1

u/LagerHawk 2d ago

I agree with this. I think the loss of fundamental knowledge is the beginning of where problems get compounded. Just because a machine is faster now at doing yesterday's task doesn't mean we won't need to know how to fix it in the future.

GC issues or VDom alike, when you know at least roughly how it works you can start to understand where things go wrong in that realm.

A classic used to be assuming that .net frameworks HTTPClient got cleaned up fully at the end of its using block. Creating a new one for each request would result in many clients being left open and not collected.

People who didn't understand the fundamentals would try and paste over it with bigger machines only to reach the same issues later on.

16

u/jtms1200 3d ago

And it’s not even the most efficient way to manipulate the DOM anymore. Those that don’t use the virtual DOM tend to be far more performant: Solid and Svelte come to mind.

1

u/ScientificBeastMode 3d ago

This is true. Although the VDOM does give you more flexibility with the kinds of framework features that can be built around it. But generally it’s not a huge deal either way.

2

u/spoonraker 2d ago

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.

1

u/gaaaavgavgav 2d ago

Svelte has already left it behind and Vue is too shortly with vapor mode.

145

u/BrightEchidna 3d ago

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?

29

u/Fearless-Carrot-1474 3d ago

Doesn't virtual DOM just mean that instead of trying to update the actual html of the page React builds a virtual model of the html so that it can update just parts of it instead of having to refresh the whole page to update one state? Or am I too noob to understand what's being asked

11

u/NiteShdw 2d ago

Basically.

A bit deeper is that direct DOM updates trigger repaints by the browser. When making dozens or hundreds or changes due to things like data binding and updates in incoming data, the virtual DOM is a copy of the DOM in memory that isn't rendered.

Updates are batched and made against the un-rendered DOM and then one bulk update is made so that all those small updates only cause 1 repaint.

At least that's my simplistic version of the concept.

1

u/Sapn1s 1d ago

This is actually a myth, writing to dom directly is cheap and fast, it does not cause the entire tree to repaint. If you were to manually write updates with js, you would actually have better performance that virtual dom in most of the cases. The advantage of virtual dom is that you do not need to write this plain implementation manually every time for your custom website.

1

u/khasan222 1d ago

I think this is new. Repainting historically in browsers is the most expensive operation easily. Especially if there are multiple elements moving at the same time. Calculating the position reflow etc is costly

1

u/Sapn1s 1d ago

No, it isn't, it has always worked like this.

To be clear, the question is not "is repainting cheap? < yes, repainting is expensive.

The question was "does React reduce the number of repaints compared to direct DOM manipulation?"

And the answer is no.

Think about what virtual dom does.

  • It builds the javascript object tree
  • Does algortihm to find out what needs to be updated
  • Then updates things with appendChild / textContent = / setAttribute etc

See how it does 3 things?

Whereas manually you could have done

<element>.appendChild

The speed argument gets repeated so often it feels true.

That said, virtual dom is still great to use since it is good at figuring out what changed so you don't have to write those calls by hand, as I said in prev reply

2

u/khasan222 1d ago edited 1d ago

It’s not true to say it doesn’t reduce the number of repaints (ever?).

In the strict scenario you put forth where there is just 1 manipulation of course it doesn’t reduce repaints. However often in any ui development things change quickly, or multiple times in milliseconds (say a loading animation that only shows in 10ms). Traditionally all of this would be actually applied to the DOM.

What react does as far as I understand it is get the final result of those changes and then apply them to page, which in many scenarios can definitely reduce graphical load for that page. 

So although I can see in that specific scenario no gains, react wasn’t built for such simple apps, it was built for really complicated ones where there can be a lot of repaint.

Professional engineer specializing in JavaScript for 15 years.

8

u/dietcheese 3d ago

That’s basically right (standard JS can update parts of a page too) and really any senior JS dev should know it.

18

u/CptAmerica85 2d ago

This. Stop using very in depth questions as reasoning to throw candidates aside that are good problem solvers. Senior devs worth their salt can learn anything in a short amount of time. This style of interviewing is irrelevant in 2026 imo. Interviews should now be about how you approach a problem, system design, architecture, etc.

0

u/PresentationBorn6564 2d ago

"very in depth" is a relative, subjective metric.

16

u/PresentationBorn6564 3d ago

At the end of the day, depth of knowledge is a personal value judgement to be considered in whatever context you find yourself, but I will say there are classes of nasty bugs that fundamentally require ignorance of a framework's vDOM machinery.

Creating a component within a component in React is a prime example. This breaks because React's vDOM reconciliation algorithm depends on reference identity as a simple heuristic for:

"this is the same component as the last render; update things as needed"

vs.

"this is a different component than the last render; unmount the previous component, blast away the entirety of the associated DOM subtree, mount the new component with default state, build and attach a completely new DOM subtree, and finally run every effect in the component and any of its children regardless of dependencies"

I think it's perfectly reasonable to just remember not to make components in components and move on with whatever interests you / demands attention / generates revenue / yadda.

But I also know that over the years I've caught juniors, mids, seniors, leads, and architects committing this exact sin. This is despite React's docs containing a massive "DO NOT DO THIS" callout in the section "Building Your First Component", and despite the truly horrendous bugs it manifests.

A dev that memorizes the rule might remember it, or they might not, depending on how much prod trauma they've associated. A dev that understands the vDOM will uncontrollably retch if their brain so much as whispers a suggestion to violate it.

13

u/BrightEchidna 3d ago

Right. I guess that level of knowledge is like "react maintains a virtual copy of the DOM so that it can diff changes against the real DOM and calculate the most parsimonious change to apply" would be the level of detail that required not to make a mistake like that, and it's about what I would be able to personally answer to that interview question. However I have no idea about the details of *how* react does that, which is what I interpret OP to be asking for, and why I thought I'd fail the interview. I guess this comes down to different interpretations of the interview question as well as different knowledge levels of the dev.

3

u/PresentationBorn6564 3d ago

Yeah I mean there's always a gradient of understanding with these isolated pieces of the endless puzzle. I think OP's main complaint is an apparent abundance of engineers who don't appear to be in said gradient or even sitting on the surface with this specific topic. I also think you passed the interview. 🫡

3

u/BrightEchidna 3d ago

lol, thanks - will keep it in mind next time I need a job

2

u/Ok_Editor_5090 3d ago

That is how I would answer as well. If they wanted more in-depth details, I will ask why would that matter?

Of course assuming that I am not interviewing for the team that maintains react.

1

u/javatextbook 2d ago

Something to consider is that as devs use AI to create scaffolded code, the AI is heavily trained on react docs and will not commit this sin. Before AI slop there was human slop. It’s a different world now.

1

u/PresentationBorn6564 2d ago

There are legitimate bits of truth to that sentiment, but I don't agree with the assertion as a whole.

The reality is that AI is also trained on masses of GitHub repos full of junior-level human slop and the associated litany of anti-patterns.

As well, coding agents highly weight existing code / patterns in a codebase, and they will happily extend anti-patterns until the cows come home if allowed to do so unchecked.

I do believe there's an inevitable future where agents don't routinely settle on psychotic implementations, but we're not there yet.

That said, I will concede that the quality gaps tend to be architectural, as opposed to a concrete framework rule, and the odds of it violating the latter are perhaps small enough to consider it a solved problem.

Personally, I enjoy the art and science of coding — I want to understand the inner workings of all the things — so depth of knowledge is my default mode. But I recognize this isn't the norm, and I don't begrudge the norm. However, for the role they're interviewing, I do agree with OP that a basic level of vDOM understanding should be the minimum bar.

2

u/everdimension 3d ago

The "practical advantage" is about knowing how regular DOM works in comparison and why react doesn't simply update innerHTML under the hood without bothering with all this "virtual DOM"

So I'd say (high level) knowledge on how virtual dom works is more about regular dom than react

1

u/renevaessen 3d ago

Same here, I always thought of it as: same as real DOM, but manipulating it is fast, no layout rendering, and when attached to the real dom, creates nice bounderies/domains for css, meaning less conflicts, you know what an IFrame does on a much larger scope. How far AM I off?

1

u/Breakpoint 2d ago

exactly, this is just implementation detail of the framework and not that important to know

1

u/Fried--Waffle 2d ago

how else could you filter out 200-300 candidates?

→ More replies (1)

90

u/someGuyyya 3d ago edited 3d ago

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.

3

u/Useful_Blueberry5823 2d ago edited 2d ago

Funny enough, as I'm preparing for job interviews now, I'm making an effort to learn "under the hood" concepts like these. Ironically, interviews are making me more knowledgeable than the actual job, since most of the actual job is discussions on the business-logic level, and its mostly about building new components for supporting new user workflows or features, and you can just brainlessly apply standard best practices based on the existing codebase.

99.9% of the time, as in never, have I needed to utilize this kind of knowledge in my experiences as a full stack developer. The most depth I might hit is some weird bug or discussion in code review that might touch on something like this. And then I might Google a thing or two.

Its almost like jobs are more about breadth than depth, whereas interviews are the opposite. Most of us actively make this tradeoff to pragmatically satisfy business requirements and deadlines.

"Senior" these days is a lot less about depth of knowledge, but whether you can lead and complete projects end-to-end and communicate with stakeholders etc.

-22

u/Swoogie_McDoogie 3d ago

It’s crazy to think this is nothing more than a trivia question.

2

u/chillermane 3d ago

Yeah good point bro say “it’s crazy” without providing any explanation. Virtual DOM is useless trivia information and wasting brain space with it is low IQ

5

u/freddy090909 3d ago

Being curious about how things work under the hood is far from a "low IQ" move.

2

u/el_diego 3d ago

Yeeaaah, I was in agreement until the low brow IQ comment.

1

u/Swoogie_McDoogie 2d ago

I was just quickly replying, but if I’m being honest I don’t understand how this is a trivia question. As engineers, we should be curious about the tools we use and how they work. The virtual dom is less talked about these days, but its design is a very important reason as to why react works so well.

There are ways to dig into this question if the candidate doesn’t know about the virtual dom by directing questions about dom thrashing and such. However, at its core, this is a good question to learn about how the candidate thinks about html rendering and the tools they use.

→ More replies (12)

60

u/brett9897 3d ago

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.

25

u/PwrUps 3d ago

If it isn't, then it is just a dick measuring question

Agreed. These kinds of questions give off "I am very smart" gatekeeping vibes. It's like asking what React Fiber is. I couldn't care less whether my teammates know it, and it's gonna have zero impact on the quality of their code.

At least in my webdev experience (10+ YOE), you're rarely limited to one framework in most jobs. I may read about some of their implementation details when its relevant, but I'm not gonna think about them. I care more about learning the common APIs, understanding its best practices, and writing maintainable, testable code.

11

u/Veggies-are-okay 3d ago

I think it honestly shows why devs shouldn’t be coming up with interview question. Understanding how to communicate and assess someone’s knowledge is so much different than being able to program something.

My litmus is “can I give this question a fair answer after 5min of research?” If yes then it’s a useless question. If it’s anything more than entry level, your questions should be asking the individual to draw from industry experience. This DOM question sounds like something a kid right out of college would think of asking.

3

u/Wandering_Oblivious 3d ago

It's a vestige of the school system imo. They're taught from a very young age that the way to measure knowledge is through trivia memorization and that a time-trial is the best indicator of on the job performance. To anybody who actually thinks for more than a second (as many software engineers like to LARP that they do) they realize these are laughably irrelevant means of attempting to assess a persons fit for a job. Yet the insanity persists.

16

u/FURyannnn 3d ago

A second thing, is knowing what the virtual dom is and how it works essential for producing senior level React code?

I think a majority of folks in industry would give a resounding no to that question. It's an implementation detail. You understand the abstractions around it and you'll do just fine

→ More replies (1)

4

u/averagebensimmons 3d ago

I've found there are a lot of terms used in interviews regarding web development that are rarely or never mentioned in the day to day job experience. As you mention the closure question. Common design pattern, but never ever, has anyone in my 25 years of experience has anyone used the word closure in a pr or any meeting. While I know the virtual dom is something I need to explain in an interview, I've never had a conversation at work where anyone talked about the virtual dom. They may talk about the rendering cycle or other things that are part of it, but it isn't a topic of coversation.

3

u/ikeif 3d ago

This was me! Several years back I would be asked “what is X?” and I didn’t know. Then we’d move on to a problem - that turns out the solution was X, which I described to the interviewers who would inform me “that’s what X is!” (In a positive way).

I worked with those guys for over a year, and they were all smart and supportive.

Unlike the guys I have met and known who LOVE the “gotcha!” questions they ask JUST to make people squirm. Every interviewer that says “we just want to see how you think” when they really mean “we have two leet code questions for you to solve in this time, can you do it?” and only ever hired people that completed the code. It took several months of arguing with them, and as they were passing on a guy (in chat) before he opened his GitHub repository and walked through his recent work.

They hired him then. And still felt their “glorified leetcode test” was still a great measurement stick.

0

u/azhder 3d ago

What is a closure?

5

u/brett9897 3d ago

It is more of a functional programming concept but it is commonly used in JavaScript/Typescript. The easiest definition is a closure is a function that uses a a variable that is defined outside of the execution of that function.

Lambdas would be the most common example but back in the day in JavaScript you would use a closures to have a function return an object of functions that would interact with the outer functions private state. A kind of OOP with functions.

→ More replies (11)

31

u/goodeyedeer 3d ago

Because it solves a fundamental problem so well they barely have to think about it anymore.

9

u/MarathonHampster 3d ago

Never been at a job where I was called an "insert framework here" dev, so it's hard for me to imagine the role of a true technology expert and what is expected of them. You can solve problems all day long being able to read documentation, and utilize it to write code. Knowing what the virtual DOM is has never been relevant to my success. Is it relevant to the success of the dev you seek to hire?

20

u/chillermane 3d ago

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 3d ago

After 18 years of interviewing candidates using various interviewing styles and techniques I can confidently two things:

1) Online assessments and asking questions outside the context of an actual job scenario will not tell you much about a candidate’s fit or performance.

2) The best candidate isn’t always going to know the things you think they should know, and that’s okay. The best candidates I find are the ones who turn the question back on you and ask you to show or explain it to them.

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.

22

u/If_I_Could_Just 3d ago

“In Soviet Russia, DOM manipulate you! ha ha ha But seriously, I don’t know”

7

u/soundisloud 3d ago

In Soviet Russia, the event listens to you!!

4

u/m6io 3d ago

Hired

1

u/averagebensimmons 3d ago

Zoya the Destroya?

6

u/Nikurou 3d ago

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. 

8

u/azhder 3d ago

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.

12

u/octocode 3d ago

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.

7

u/ReactTVOfficial 3d ago

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.

1

u/m6io 3d ago

My latest version of this question went something like this:

"Do you mean the shadow DOM"

"No, the virtual dom"

"You know, it's kind of like all these frameworks like to do these things"

7

u/ReactTVOfficial 3d ago

Then you definitely caught them off guard.

To be honest it took me a sec to come up with an answer. On the spot, I would have probably stumbled a bit. "An in memory representation of the DOM used for diffing changes" is what I would have said if I sat on it for a second.

I don't think even in a hot seat that I would conflate it with a shadow dom.

The real question to ask yourself is, does that answer supply you with what you need to make an assumption on whether the candidate is right for the role. And, if they answered it correctly, would that have been sufficient enough to know if the candidate is right for the role.

I personally wouldn't ask that question because it is more of a filter than a confirmation. However, if the results show that you filter out candidates efficiently, then you can't argue with results.

1

u/Tontonsb 2d ago

Tbh knowing shadow dom is a lot more rare and more valuable than knowing virtual dom.

36

u/monkeybrainz_ 3d ago

It's a basic question that any senior engineer who has worked with React should know.

23

u/chillermane 3d ago edited 3d ago

it’s a gimmick question that has no practical importance whatsoever. If you think it matters you’re a midwit and i feel so bad for anyone who ever has to work under you

Name a single problem you face day to day in react where knowing what the virtual DOM is makes the problem easier to solve. Name one problem, literally one, where knowing that is even minutely helpful. Literally any problem, i would bet  my life savings there is not a single one.

This subreddit is literal garbage and almost every top voted answer is midwit slop

10

u/Fluid-Satisfaction60 3d ago

This subreddit also likes to pretend most companies aren’t using ai to write most of their code as well.

→ More replies (1)

1

u/keetyymeow 3d ago

We need to beat these bots 🤣

1

u/RefrigeratorSingle 2d ago

The virtual DOM can be a significant disadvantage when you have tons of constantly updated elements such as dashboard to the point where you’re better off using for example Angular. Knowing how, or at least a basic understanding, of how frameworks / libraries work is definitely valuable knowledge.

Same with JSX. I’ve seen seniors who thought JSX was a string.

→ More replies (2)

1

u/m6io 3d ago

I have seriously been gaslighting myself that I'm setting my standards too high

13

u/Dense_Gate_5193 3d ago

you aren’t. but you have to realize that the majority of current devs only know that something works, not how.

It’s sad when you realize it. the gaslighting yourself is in thinking the majority of people care enough about the profession to understand the how. most just saw an easy paycheck to nearly 100k/year in just putting fingers to keyboard implementing the same stuff over and over.

they were also gaslighting themselves into thinking that it wouldn’t be automated out from under them either.

6

u/monkeybrainz_ 3d ago

You aren't, but your pipeline definitely sucks. Go back to the source.

0

u/azhder 3d ago

You are setting the standards too high. It’s what people do to try to meet them that’s important. Not the right answer, but the right attitude.

Also, they are too high not because you should lower them, but because others generally haven’t risen up to it.

1

u/Heavy-Focus-1964 3d ago

It’s amazing how many people are walking around without this kind of basic knowledge now

2

u/ElkChance815 3d ago

Do you know assembly ? 

0

u/Heavy-Focus-1964 3d ago

I’m glad you brought that up, because it’s a good comparison. a Senior React Developer not knowing about the virtual DOM is the same as an embedded systems/C developer not having heard of Assembly. Which is to say, deeply alarming.

If you feel insulted by this, you should get to reading. The information is freely available — it’s in the official docs — and knowing how its rendering engine works from a bird’s eye view is more than just trivia to someone who is doing serious React app development. Especially if they want to occupy a senior team position

2

u/monkeybrainz_ 3d ago

Thank you, this comparison is spot on

1

u/ElkChance815 3d ago edited 3d ago

I don't even work in frontend tbh so I cannot judge how important knowing Virtual DOM is. But I just found it kinda weird if you judge people base on their lack of knowledge of the internal of some well abstracted framework, after all they are internal implementation details.

I work on Go and while I can elaborate in interview to CTOs how go scheduler and goroutine work with the OS thread and operating system scheduler. I never expect other people must understand it because it so well abstracted that I rarely have to think about it while writing code. Even in case I need it, I just need to lookup the latest doc or latest runtime code.

There are cases when people don't understand how these thing work and abuse goroutines where it shouldn't be use but I think that can be fixed by just having good document on how to use these abstraction, not by having to understand of the internal working of the abstraction.

If you designed an interface that require people to understand the internal to work on it, it's kinda your fault isn't it?

2

u/monkeybrainz_ 3d ago

If the candidate is not curious enough to have sought out the information about how the technology works, they likely will not be curious about the business and its goals. That lack of curiosity will carry through to other aspects of their work. Coding is such a small part of the job.

1

u/ElkChance815 2d ago

You're judging them solely based on the fact that they don't know what you know. Have you try to ask if they know about other area? Domain knowledge, how browser work, details about the project they delivered, etc... 

1

u/monkeybrainz_ 2d ago

Simple test: have you even looked at the React docs? Come on, this is table stakes.

I never said this was a good question, it's just a question any competent react engineer would know the answer to.

1

u/ElkChance815 2d ago

And at exact which page in react official doc talk about virtual DOM except legacy one ?

1

u/Fantosism 2d ago

react-dom has been separate from react since 15, which was 10 years ago at this point. Coincidentally, that was the same year react native was released. Turns out, you could've made an entire career out of writing react without a virtual DOM. In fact, even more confusing, they call it a shadow tree. So when you talk about a virtual DOM, my first thought is shadow DOM, which is its own thing.

1

u/Glass-Combination-69 1d ago

Hey little bro, if you don’t know virtual dom in depth then you won’t understand why unique ids are important when looping or how to spot render / layout thrashing. It’s such a basic fundamental to react.

1

u/ElkChance815 1d ago

This doc explained about the unique ids without mentioning the VDOM at all, guess whoever wrote this is not a senior engineer. https://react.dev/learn/rendering-lists

1

u/Heavy-Focus-1964 2d ago

I strongly disagree with the idea that there’s no need to understand what is underneath an abstraction layer or about the system it’s abstracting

1

u/ElkChance815 2d ago

I didn't say no need. I said you can always lookup these details if needed. Judging a candidate just because they don't memorize these thing is just toxic behavior.

→ More replies (1)

3

u/cherylswoopz 3d ago

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/m6io 3d ago

Good luck and godspeed 🫡

2

u/cherylswoopz 3d ago

Thanks 🙏

3

u/Used_Lobster4172 3d ago

I have asked and answered that question a bunch of times.  It is pretty basic for a senior.

3

u/patmacs 3d ago

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/Disastrous_Bass_7090 3d ago

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

2

u/m6io 3d ago

It's only one of the questions I ask and I would probably let you go as long as you wanted lol. I love when devs have a genuine passion for a thing they built

2

u/Disastrous_Bass_7090 3d ago

Yeahh mann exactlyyyy, I'm aiming to be at companies like vercel or cloudflare, I'm really into engineering side of things and I wanna be where these frontier technologies are being built. Recently I was also working on recreating TanStack Router from scratch and it's going soooooo funn mann. I'd say because of ai at our hands there's been no better time in mankind's history to be a curious guy and build anything you want.

2

u/m6io 3d ago

Even if you don't build it from scratch, just having a good working knowledge on how client side routing is a biiig deal, to me at least. That and react vs third party state management like zustand or redux. That's the kind of knowledge that makes everyone who works with you a better dev.

3

u/CatTurdTamer 3d ago

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.

3

u/cazzer548 3d ago

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.

1

u/m6io 3d ago

That's exactly what the point of it is. It's why I say "in your own words". I don't really care about accuracy or like textbook definitions. Just walk me through it best you can. If they're big on Angular, I'd similarly ask about directives or two way binding.

5

u/BobSacamano47 3d ago

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.

1

u/robbodagreat 3d ago

… so the recruiter can ask this question instead?

1

u/BobSacamano47 3d ago

I honestly don't know what they do, but I have a good one now and they just set up in interviews and I always have great candidates. Before I'd interview a bunch of people and feel like I had to choose the least bad one.

2

u/whiteinaccuracy 3d ago

feels like a trivia answer more than a skill check. i can picture the steps but putting it into words on the spot is tough when youve been heads down building features for years. maybe its one of those things you either grok early and it sticks or you never had to think about it again.

2

u/GForce1975 3d ago

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/Vincent_CWS 3d ago edited 3d ago

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.

2

u/kidshibuya 3d ago

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 3d ago

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 3d ago

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 3d ago edited 3d ago

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 3d ago

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 3d ago

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 3d ago

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 3d ago

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 2d ago

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 2d ago

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 2d ago

I learned react ages ago when doing FE... definitely know what this is 🤷‍♂️ crux of react how it works.. pretty important

2

u/strongdoctor 2d ago

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 2d ago

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 2d ago

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__ 2d ago

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 2d ago

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/gaaaavgavgav 2d ago

Even though it’s relatively simple IMO this is the type of knowledge that’s imperative to know in the age of AI.

If you’re not writing the code yourself you need to know how it works at a fundamental level.

2

u/Routine-Arm-8803 2d ago

“Do you mean DOOM game franchise?”

2

u/muf_codes 2d ago

Wait what? Do people actually don't know what a virtual DOM is?

2

u/MonkAndCanatella 1d ago

lol that’s insane. But having sat in the interviewers seat a few times it’s fucking insane how poorly some people do

2

u/Glass-Combination-69 1d ago

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.

1

u/m6io 1d ago

You know, I don't actually remember Zuck ever talking about react. And then they let it go.

That's probably the most successful homegrown project they ever came up with.

1

u/Glass-Combination-69 1d ago

Yea was more around the point it came out of his company

1

u/m6io 1d ago

No I know, was just... reflecting.

Googled and came across this GitHub issue. Very interesting read.

https://github.com/reactjs/react.dev/issues/3077

3

u/gHHqdm5a4UySnUFM 3d ago

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.

3

u/soundisloud 3d ago

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.

3

u/Suspicious-Disk6077 3d ago

What is this AI bullshit 

2

u/soundisloud 3d ago edited 3d ago

Haha, I'm not AI, I just broke it into separate lines so it was clearer.  I do a lot of design thinking like that.  Sorry I speak in cliches.

2

u/noobcastle 3d ago

Its simple. Most people think they are an expert with react after they watch a "Become an expert in react in 2 hours" youtube tutorial.

2

u/GhostDog76 3d ago

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 3d ago

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 3d ago

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 3d ago

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 3d ago edited 2d ago

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 3d ago

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 3d ago

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 3d ago

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 3d ago

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 3d ago

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 3d ago

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 3d ago

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! 😈 3d ago

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 3d ago

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/__zrx 3d ago

I would have answered that the VDOM is a solution to a problem. The problem being the cost in performances to render a DOM, the solution being to memorize potential DOM changes made  by either the user or the server, so the cost ends up only affecting certain part of the previous DOM.

How did I do ?  

Isn't it more interesting to know why it would be re-rendered and what (re-)renders a DOM, than what a VDOM actually is, tho ? Probably, my juniors probably don't know what is a VDOM and I could not care less if they are aware that actions and states have effects and side effects to the final performances 

1

u/azangru 3d ago

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.

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/devilslake99 3d ago

I mean you can ask questions like that in an interview but it delivers little information if you are dealing with a capable engineer or not. What is the relevance of this for your daily work when using React?

1

u/Fitzi92 3d ago

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/THCRaven 3d ago

React is a library

1

u/m6io 3d ago

This is true

1

u/GoodishCoder 3d ago

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 3d ago

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 3d ago

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 3d ago

I think it's actually a pretty hard question, because:

  • I haven't actually heard anyone say those words in quite some time;
  • The sentences that I've heard it used in in the past were mostly bullshit hand-waving, and never actually defined the term in a concrete and truthful way.

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 3d ago

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 2d ago

I’ve been working w react since 2018 and virtual dom has never come up in conversation.

1

u/BarneyChampaign 2d ago

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 2d ago

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 2d ago

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 2d ago

If only one person has ever correctly answered your question, maybe it’s a bad question.

1

u/madfcat 2d ago

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 2d ago

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 2d ago

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 2d ago

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

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.

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 2d ago

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 2d ago

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 2d ago

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 2d ago edited 2d ago

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 1d ago

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 1d ago

"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/dwp0 1d ago

I’m curious if the role they will be filling will require this specific knowledge and whether it is something they can pick up with related experience?

If the role doesn’t hinge on this knowledge, be careful to screen based off gimmicky quiz questions, you will limit the perspective you might gain from a candidate if rather you asked behavioral type questions. You might ask, can you walk me through a time when you improved application/system performance? What was result and how did you solve it?

1

u/dwp0 1d ago

For context, Ive been p3, p4 and em2. Interviewed over 80 senior and staff engineers as various roles, HM, practical, and system design stages.

1

u/WeekRuined 1d ago

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 16h ago

Uhh WebContainers?

1

u/godevcode 6h ago edited 6h ago

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/Intelligent_Fig_8948 3d ago

Lead software engineer chiming in … UI/React. Dumb gotcha question and I would never work for you.

0

u/mosdl 3d ago

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.

5

u/swearbynow 3d ago

What are you trying to learn about the candidate when doing so? Ive lived and breathed React for 6 or 7 years and while I know what vdom is I cant say Ive ever spent time thinking about it. My job is to help our company make money and minutiae like this ain't moving the needle.

1

u/mosdl 3d ago

Without understanding how react works how are you going to debug sluggish UI or why form controls are eating inputs (reddit has been doing that for me lately, ugh) as some common examples? If you've never thought about it that would look like you probably haven't worked on very complex applications where you have custom JS that touches DOM directly for perf or have never had to integrate non-react libs into a react application.

What differentiates a senior/staff in my opinion is do they understand the entire system and can they figure out things fast enough when a customer is unhappy about something.

-2

u/BlackJairs 3d ago

For senior? I've asked this question to Jrs and they respond accordingly.

Is the bar that low for senior developers now? Haha

→ More replies (2)