views:

8552

answers:

14

I have an interview coming up for a JavaScript Engineer position that I expect will be on advanced JavaScript topics. I'm sure there will be questions on closures, but other than that what kinds of topics and questions should I expect?

+5  A: 
  • Frameworks - jQuery, Protoype etc
  • Cross-browser compatability
  • AJAX
Greg
+6  A: 

As Greg mentioned, they'll definitely ask you about framework experience.

Also:

  • Core Javascript (you'd be surprised how many people don't know it)
  • Event delegation
  • Optimization

And always fun, be prepared for a coding test.

Mike Robinson
+1 Optimization is a good one
Greg
+32  A: 

If I was interviewing someone, my list would look something like:

  1. Prototype inheritance vs Classic inheritance
  2. Closure.
  3. Why extending built in JavaScript objects (like how Prototype library does) is not a good idea.
  4. Difference between document load event vs document ready event.
  5. What are the different JavaScript frameworks you have used. And more importantly, which library do you prefer and why?
  6. Event delegation
  7. Cross Browser Scripting a. What is browser detection? What is feature detection? Which one is preferred?
  8. Optimizing JavaScript heavy pages
  9. Some sort of code test.
SolutionYogi
That's because he mentioned closure already
Mike Robinson
My bad, I should have read the question more carefully. :)
SolutionYogi
Nice list! I would add a question asking for a description of JavaScript's concurrency model.
Jesse Hallett
+8  A: 
  • Necessity of Frameworks/libraries and what their abstractions provide. Talk about the benefits of using a library like jQuery or YUI.
  • Graceful degredation / progressive enhancement, plus how these two ideas merge into application design and development.
  • Prototypal inheritance; plus its limitations and benefits versus class-based inheritance.
  • Know what your favourite JavaScript engine is and why... Is it V8? Why?
  • Know what closures are and how you use them to avoid unecessary obtrusiveness. Is a closure just a function, or is it more?
  • Understand scope, scope chains etc.
  • DOM Events, + the DOM API in general. Know more than innerHTML, know how to traverse the DOM in plain JavaScript (without a library)
  • Ajax and the core technology behind it; XHR. Know how to make XHR work in browsers that don't support it.
  • Why extending native JavaScript objects is a bad idea; does it lead to bad habits?
  • Know regular expressions and how they're implemented in JavaScript.
  • DOM Event propagation, what is it? How does it compare to event capturing. Difference between the W3C event model and other models (IE etc.).


Most of the above won't come up... But it's all stuff I think every "JavaScript Engineer" should know.

J-P
+10  A: 

What is the difference between == and ===

Chris Brandsma
What's `==`? ;P
strager
@strager: when can you start?
Chris Brandsma
@Chris Brandsma, Today!
strager
+1  A: 

does javascript have associative arrays?

what sort of binding issues does one encounter with javascript? (if you are interviewing for a large scale web app job, this is a major issue that a JS engineer encounters everyday, but average devs are not aware of)

why should you always do:

var x = 1;

as opposed to

x = 1;

when declaring new variables (note: tough answer to find, but HUGE HUGE HUGE difference between the two, you just don't encounter problems with it often enough to be aware of the difference)

If you are an average JS developer, the best prep i can recommend to you is to read Doug Crockford's "Javascript: The Good Parts", it will hit upon a number of issues described by the questions already given and make you aware of the really bad parts of javascript you should avoid, thus giving you a good prep for the interview.

strife25
A: 

I would ask them which are your favourite javascript books. Books like jQuery in Action and Javasctipt - The Definitive Guide by David Flanagan have been a massive help for me in groking javascript.

Jake Scott
+2  A: 

In addition to the above, I think that asking some trickier, less known Javascript "gotchas" can't hurt - perhaps something like the following?

What value would the following code alert?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
    <head>
        <title>Test</title>
        <meta name="keywords" content="lol">
    </head>
    <body>
        <textarea id="keywords">Lol I'm in ur html</textarea>
        <script type="text/javascript">
            var keywords = document.getElementById("keywords");
            alert(keywords.value);
        </script>
    </body>
</html>

(For those who look at this and may not get it, IE6/7 (Maybe 8, I'm not sure of this at the moment) have a bug in their .getElementById() implementation wherein, if there's an element with a name that's the same as an id later in the document, the browser will return that element instead of the correctly id'd element.)

Ryan McGrath
God, that's a nasty one. Thanks for the mention!
Adriano Varoli Piazza
That would be the worst interview question ever. What info do you expect to get out of that? You either find out A. the dude somehow has been a victim of this insidious big, or B. (most likely) the dude has no idea because theres no way to know that bug exists unless you've come across it before.
B T
Never good when you can't provide the answer to your own question during an interview. What happens in IE8?
Mike Robinson
8 works as it should. While I appreciate your attempt at correcting someone and bolstering your own ego, this was an answer written over a year ago in response to an open-ended question that didn't require too much thought. Chill. ;P
Ryan McGrath
+1  A: 

There are two tests which would test your skills on java script 1. Javascript Interview Questions 2. Java Script regular Expression quiz

vsingh
+4  A: 

For anyone interested in Javascript quiz, I posted one yesterday. The goal is to test knowledge of scoping, function expressions, order of evaluation, process of variable and function declaration, as well as semantics of "hoisting", etc.

kangax
+1 I really like your blog!
Gumbo
+4  A: 

Ask them to explain why

 '7' + 4 gives '74'

whereas

 '7' - 4 gives 3
Yada
+1  A: 

What is the result of a.foo(2)?

var a = (function(y,x) {
    var x = null;
    return {
        foo: function(x){ return this.bar(x * y); },
        bar: function(x){ return x + y; }
    }
})(3,4);

Answer:

  • function(3,4) // 4 is not used in this example, y becomes 3

  • foo(2) // x is passed in as param

  • return bar(2 * 3) // y is 3 from initialization

  • bar(6) // x is passed in as param again

  • return 6 + 3 // y is still 3 from init

9

Jason
Hey, can you explain this in detail . .. can't seem to get it (nOOb)
Stewie
Updated with detailed answer :)
Jason
A: 

why '7'-4 comes as 3 ?

alter
You should ask this question using comment feature provided below the above answer. This will be downvoted
pramodc84
@pramodc, sorry I was not able to comment due to some technical problem. So I added another answer. Anyways, I am still looking for the answer.
alter
- is arithmetic operator and it tries to subtract 3 from 7 which is typecast from char '7' and result in 3
pramodc84