views:

1254

answers:

8

What are good questions to determine if applicant is really a pro JavaScript (browser side) developer ?

Questions that can distinguish if someone is not an ad-hoc JavaScript programmer, but is really doing professional JavaScript development, object-oriented, reusable, and maintainable.

Please provide answers, so an intermediate and ad-hoc JavaScript programmers can interview someone more experienced, coming up with answers to quite few of those advanced questions will elude me. Please avoid open questions.

Please keep one interview question/answer per SO answer for better reading experience and easier interview preparation.

It's possible duplicate, but there only questions and no answers (mostly):

+2  A: 

Ask how accidental closures might cause memory leaks in IE.

Robusto
And firefox....
Kragen
+2  A: 

Ask "What unit testing framework do you use? and why?"

You can decide if actually using a testing framework is really necessary, but the conversation might tell you a lot about how expert the person is.

tvanfosson
As a reference, QUnit is amazing: http://docs.jquery.com/QUnit
Goyuix
+5  A: 

Ask about "this". This is one good question which can be true test of JavaScript developer.

Anil Namde
Can you provide a link to some good article?
WooYek
I think this question will help http://stackoverflow.com/questions/2148451/help-this-is-confusing-me-in-javascript
Anil Namde
+10  A: 

(I'm assuming you mean browser-side JavaScript)

Ask him why, despite his infinite knowledge of JavaScript, it is still a good idea to use existing frameworks such as jQuery, Mootools, Prototype, etc.

Answer: Good coders code, great coders reuse. Thousands of man hours have been poured into these libraries to abstract DOM capabilities away from browser specific implementations. There's no reason to go through all of the different browser DOM headaches yourself just to reinvent the fixes.

Matt
The results of thousands of man hours are entirely dependent on the ability and experience of the people putting in those hours. A library that a lot of effort has gone into isn't necessarily going to be any good.
Tim Down
@Tim Down: certainly, but if you find a reputable package, then nearly all parts of the package will have been reviewed by capable people. And as a user of an open source package, you can submit corrections when you find mistakes, adding your expertise as well.
PanCrit
+5  A: 

Ask them how they ensure their pages continue to be usable when the user has JavaScript turned off or JavaScript isn't available.

There's no One True Answer, but you're fishing for an answer talking about some strategies for Progressive Enhancement.

Progressive Enhancement consists of the following core principles:

  • basic content should be accessible to all browsers
  • basic functionality should be accessible to all browsers
  • sparse, semantic markup contains all content
  • enhanced layout is provided by externally linked CSS
  • enhanced behavior is provided by [[Unobtrusive JavaScript|unobtrusive]], externally linked JavaScript
  • end user browser preferences are respected
insin
+11  A: 

Because JavaScript is such a small language, yet with incredible complexity, you should be able to ask relatively basic questions and find out if they are really that good based on their answers. For instance, my standard first question to gauge the rest of the interview is:

In JavaScript, what is the difference between var x = 1 and x = 1? Answer in as much or as little detail as you feel comfortable.

Novice JS programmers might have a basic answer about locals vs globals. Intermediate JS guys should definitely have that answer, and should probably mention function-level scope. Anyone calling themselves an "advanced" JS programmer should be prepared to talk about locals, implied globals, the window object, function-scope, declaration hoisting, and scope chains. Furthermore, I'd love to hear about [[DontDelete]], hoisting precedence (parameters vs var vs function), and undefined.

Another good question is to ask them to write a sum() function that accepts any number of arguments, and returns their sum. Then, ask them to use that function (without modification) to sum all the values in an array. They should write a function that looks like this:

function sum() {
  var i, l, result = 0;
  for (i = 0, l = arguments.length; i < l; i++) {
    result += arguments[i];
  }
  return result;
}
sum(1,2,3); // 6

And they should invoke it on your array like this (context for apply can be whatever, I usually use null in that case):

var data = [1,2,3];
sum.apply(null, data); // 6

If they've got those answers, they probably know their JavaScript. You should then proceed to asking them about non-JS specific stuff like testing, workflows, version control, etc. to find out if they're a good programmer.

bcherry
Good question.Small nitpick: I believe you mean "return result" instead of "return i".Pro-tip: Set up a nice little test environment to test code before posting ;-)
MisterMister
wow, that's a silly mistake. I test most of my code at jsFiddle before posting, but didn't test this one. Thanks :)
bcherry
+5  A: 

Basic JS programmming

  • Scope of variable
  • What is Associative Array? How do we use it?

OOPS JS

  • Difference between Classic Inheritance and Prototypical Inheritance
  • What is difference between private variable, public variable and static variable? How we achieve this in JS?
  • How to add/remove properties to object in run time?
  • How to achieve inheritance ?
  • How to extend built-in objects?
  • Why extending array is bad idea?

DOM and JS

  • Difference between browser detection and feature detection
  • DOM Event Propagation
  • Event Delegation
  • Event bubbling V/s Event Capturing

Misc

  • Graceful Degradation V/s Progressive Enhancement
pramodc84
this is for hiring JS Gurus.
andreas
@andreas - Yes. Super set of questions. We can choose subset of these appropriately
pramodc84
A: 

intermediate programmers should have technical mastery of their tools.

if he's passed the technical phone screen-esque questions above, make him sketch out something stupid on the spot, like an ajax url shortner. then grill him on his portfolio. no amazing portfolio = intermediate developer in this domain and not the guy you want in charge of your shiny new project.

Dustin Getz