JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages. The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.
Does the programming language you use for coding interviews matter? The answer is yes. Most companies let you code in any language you want - the only exception I know being Google, where they only allow candidates to pick from Java, C++, JavaScript or Python for their algorithmic coding interviews.
Understand how the browser deals with user input, web requests, and events in general. Know how to recognize and write asynchronous code. Understand how JavaScript is both asynchronous and single-threaded. Higher Order Functions — Understand that functions are first-class objects in JavaScript and what that means.
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
andx = 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.
Basic JS programmming
Scope of variable
Associative Array
? How do we use it?OOPS JS
Difference between Classic Inheritance and Prototypical Inheritance
difference between private variable, public variable and static variable
? How we achieve this in JS?add/remove properties to object
in run time?inheritance
?extend built-in objects
?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
Ask about "this". This is one good question which can be true test of JavaScript developer.
(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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With