Thanks for writing this up! These questions that involve walking the DOM are always good practice. I imagine the back and forth could go like this:
I'll use jQuery's $('.someclass')
Ok, how about no jQuery?
I'll use document.querySelectorAll('.someclass')
Ok, how about if the browser didn't support qsa?
I'll use document.getElementsByClassName('someclass')
Ok, let's theoretically say the browser doesn't support that either.
Dammit! Ok, time to write the recursive DOM-walker.
These questions for senior JavaScript positions always seem to involve some sort of manual DOM traversal. I remember bombing an interview because I couldn't whiteboard a DOM contains function from scratch. If I had to figure that out on my own, I could've eventually done it in a normal work environment, but these folks assigned a lot of value to being able to whiteboard it, which I hate...
In a real job situation we've only used whiteboards for architecture diagrams, which is definitely a practical skill. Folks almost never write code on whiteboards except when actually administering other interviews...
I remember bombing an interview because I couldn't whiteboard a DOM contains function from scratch. If I had to figure that out on my own, I could've eventually done it in a normal work environment, but these folks assigned a lot of value to being able to whiteboard it, which I hate...
I know what you mean. I had a whiteboard question about something silly (how would you reimplement a bind-like function yourself) and I blanked. Once I got onto the buss after the interview I smacked myself on the head because I figured it out ...
Isn't this a tree traversal? I mainly code in JS and I've never had this as an interview question. My intuition is that dfs or bfs is what they want to hear. But then again, without looking at MDN I don't know if I can answer this.
Yeah, it's basically tree traversal. And let's face it - each of us would do a "mdn + question" query in Google. We're not expected to know the answer to life, the universe and everything - we're expected to know how to ask the question, where to find the answer and know how to use it.
I've done that when I've interviewed people. JSfiddle with its Collaboration worked decently well (I was the remote person , so we had to have a screenshare of some sort). Lots of "finish this, replicate that, look at this code and talk about how it works" Just like whiteboarding, it usually devolved into more discussion and no completed code (or utter defeat and no code-- the joys of hiring for "entry level"), but that's par for the course, I think.
It worked pretty well, though, as a sort of whiteboard that didn't depend on handwriting skill.
I like this. I've practiced enough "puzzles" to grok most interview questions. I would rather talk about design and architecture. I think a lot of interviewers forget it's a two-way street.
19
u/franksvalli Jul 22 '16 edited Jul 22 '16
Thanks for writing this up! These questions that involve walking the DOM are always good practice. I imagine the back and forth could go like this:
I'll use jQuery's $('.someclass')
Ok, how about no jQuery?
I'll use document.querySelectorAll('.someclass')
Ok, how about if the browser didn't support qsa?
I'll use document.getElementsByClassName('someclass')
Ok, let's theoretically say the browser doesn't support that either.
Dammit! Ok, time to write the recursive DOM-walker.
These questions for senior JavaScript positions always seem to involve some sort of manual DOM traversal. I remember bombing an interview because I couldn't whiteboard a DOM contains function from scratch. If I had to figure that out on my own, I could've eventually done it in a normal work environment, but these folks assigned a lot of value to being able to whiteboard it, which I hate...
In a real job situation we've only used whiteboards for architecture diagrams, which is definitely a practical skill. Folks almost never write code on whiteboards except when actually administering other interviews...