Q: How do you implement an extend function that takes an object and extends it with new properties and makes it work on n levels of recursion? Basically, duplicating a jQuery extend.
This question shows whether candidates have an understanding of basic programming concepts such as recursion, says Jonas Huckestein, co-founder of conference-calling startup HipDial.
Q: Can you write a function that takes an object and appends it to the DOM, making it so that events are buffered until the next tick? Explain why this is useful?
This last part only applies in browser-side settings where it can dramatically increase performance, he says.
Q: How do you write an event emitter base class that allows you to add event listeners?
This question can nicely lead into architectural questions, Huckestein says, such as: “How would you make an event emitter that’s distributed?”
Q: What is the concept of “functions as objects” and how does this affect variable scope?
New hires at Vector Media Group are asked this mid-level question, says Matt Weinberg, president of development and technology at Vector, a web development and Internet marketing agency in Manhattan.
Weinberg added: “When they explain what excites them about these frameworks or utilities, I can get a good sense of the kind of work and style they prefer.”
Q: What is the difference between .call() and .apply()?
“The really important part of this discussion is not that they remember which is which, but more that the interviewee understands that the “this” keyword is not as predictable as in other languages, and that functions can be applied to other objects, and generally be treated as data,” he says.
Q: What is event bubbling in the DOM?
The main goal of this question is to establish that the applicant knows what order events will be propagated in the DOM – most specific to least specific.
“Not everyone may know this by the name ‘event bubbling,’ so asking about event propagation in general is sometimes needed. Ideally, this is an opportunity to discuss event models outside of the DOM, and ask follow-up questions about routing based on user actions, looking for techniques popularized with frameworks like backbone.js, or AngularJS,” Kubasik says.