Interviewing With Me? Here’s an Easter Egg. I’ll ask you this JavaScript Question During the Interview.

We’re hiring in my group.

Cool, right?

So, I’m once again interviewing. Yay me.

Since I’m no longer running a group I don’t have to worry about any of the administrative type things (“this is what the company is about,” “this is what we do,” etc.) That’s good as it just allows me to test people on technology. That’s really my favorite part of the interview process anyway. Win.

The following is a tiny snippet I’ve been using to test people’s knowledge of JavaScript fundamentals.

Why share it here? For one thing it’s kind of interesting to me since it’s a very small snippet but it can expose a lot about the way the person approaches the language. Basically, if you can get this and you’re still pretty inexperienced you’ve probably read a book, taken a class or read a blog post or article written by someone smart. That’s a bonus.

And then there’s the Easter Egg part. Meaning, I’m still going to be using this going forward with the answer sitting right out here in the open. Why?

Here’s how I see it. If a candidate:

  1. Has researched me before interviewing with me
  2. Read enough of my blog to find this post
  3. Read it and learned enough about the topic to spit it back at me in the context of an interview- including the terrible, probing questions I will ask to try to get past the surface knowledge

So, even if they didn’t know the answer before reading this post they have some other positive qualities that more than make up for a bit of a hole in their technical knowledge.

In other words, there are two ways to get the right answer to this particular question. Either one is going to impress me.

Anyway, while we’re a jQuery shop, we also want people who know, you know, actual JavaScript, so I always include a pure JavaScript question to test people.

This is what I’ve been using. To me, this could be answerable by anyone that I’d want to hire who’s moved beyond the Search Google -> Copy -> Paste cycle of JavaScript development. Thanks to the jQuerys of the world, there are a lot of people who can do plenty of useful work who don’t know anything about how JavaScript actually works. That’s great, but if you’ve actually looked under the hood in the way that answering this question correctly implies you’re probably going to be a better, more useful fit.

Getting this wrong isn’t a killer in the process, of course. This is a more junior role, so I don’t need to have a candidate be a super expert at everything to make the grade.

Are you ready?

Here’s the code I show them:

//outputs [1,2,3,4,5,1,2,3,4,5]

The instructions are: Make that statement work.

The answer, if you know what’s what, can be very simple. Here’s an example:

Array.prototype.duplicator = function(){
    return this.concat(this);

Simple, yes. The thing is, to get there you need to know about a few things that are Good to Know.

  • The original example uses an Array literal to create an array (some people don’t get that pattern)
  • The solutions returns a value and correctly uses this to bind to the Array
  • Using Array.prototype to extend the native Array with the useless duplicator() method

For the pirate/ninja/jedi crowd this might seem silly basic, but the plain fact is there are people out there who are making good money coding JavaScript who would fail at one or more of these hurdles. I can start to sort candidates into one or the other camp with just the one line.

Not too shabby.

And if they get the answer by reading this far? Hi, good luck with the rest of the interview (cue dramatic music and maniacal laughter)

7 thoughts on “Interviewing With Me? Here’s an Easter Egg. I’ll ask you this JavaScript Question During the Interview.

  1. definitely. Well, not the screaming part, since I want them to stay in the room, but they’d get big bonus for even being able to hint at that.

  2. What advice would you give a newbie web developer who wants to get hired to code rather than wait tables? I’ve put a few simple sites together and play around occasionally with an attempt at building a game engine in JS just for the learning opportunities, but I don’t feel like I could pass a test on javascript without reference information on hand.

    A problem like this I probably wouldn’t be able to answer quickly without looking up some reference material. For instance it hadn’t occurred to me that an array literal would have Array.prototype — I probably would have tried Object.prototype first or assigned the array to a variable first and prototyped that. It’s just working in terms I’ve used before since my JS vocabulary isn’t very strong.

    Once I go to tackle a problem I can get things figured out, doing the research as necessary, but my knowledge of the language(s) is just not very broad or deep yet. I’d hoped I could start doing entry-level work and become more of an expert while getting paid, but a post like this makes me feel like I really should just go back to college for CS if I ever want to get hired.

    What do you think?

  3. Well, one of the things to keep in mind (at least interviewing with me) is that a lot of the problems I’ll give you are open ended or aren’t really pass/fail. A lot of times I’m just as impressed by the way someone will work through a problem they don’t know the answer to. All developers have to deal with things we don’t have easy answers to, entry or mid-level developers are going to have to do it all the time, so it tells me a lot watching how someone will work through a problem. For example, even if you don’t get the inheritance part, you could still show me something vital by writing a reasonable repeater() function.

    As for getting started without going back to school… I got started exactly the same way you want to get started, so it’s possible. I built some sites, got a temp job doing HTML and the rest is history. Sure this was during the dot-com boom, but it still happens.

    If you want to prepare for people like me asking you questions like this you can do it a lot cheaper than going back to school. Reading books like JavaScript: The Good Parts, ppk on JavaScript, 1/e or Object-Oriented JavaScript will get you a long way. Also, Crockford’s recent video series is a great window into the language.

    Good luck!

  4. Thanks for the insight. I’ve already started watching Crockford’s videos, and I’ll put those books on my list.

Leave a Reply

Your email address will not be published. Required fields are marked *