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?
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.
If I was interviewing someone, my list would look something like:
- Prototype inheritance vs Classic inheritance
- Closure.
- Why extending built in JavaScript objects (like how Prototype library does) is not a good idea.
- Difference between document load event vs document ready event.
- What are the different JavaScript frameworks you have used. And more importantly, which library do you prefer and why?
- Event delegation
- Cross Browser Scripting a. What is browser detection? What is feature detection? Which one is preferred?
- Optimizing JavaScript heavy pages
- Some sort of code test.
- 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.
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.
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.
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">
<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.)
There are two tests which would test your skills on java script 1. Javascript Interview Questions 2. Java Script regular Expression quiz
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.
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