Interview questions for senior roles won't (or at least shouldn't) be about language specifics but instead about managing a team, distributing technical work, managing timelines etc. Needless to say, depending on the company, ymmv.
Ask HN: “Expert Level” JavaScript questions?
21–30 of 54 posts
Re: Ask HN: “Expert Level” JavaScript questions?
#22Why creating an element and afterwards setting it to invisible, will never end with a 'blinking' element.
Re: Ask HN: “Expert Level” JavaScript questions?
#23I agree with others though that you probably won't get the trivia treatment, I wouldn't give one and I don't see them being done by coworkers... But it doesn't hurt to be prepared. So long as you don't present yourself as a "Master" I would think the knives would be less likely to come out. Things like this github has https://github.com/denysdovhan/wtfjs are on the mean spectrum to use against some so-called master, the meanest might probably be demanding they do something with representations like in http://patriciopalladino.com/blog/2012/08/09/non-alphanumeri...
Re: Ask HN: “Expert Level” JavaScript questions?
#24Explain why ['1','1','1'].map(parseInt) returns [1, NaN, 1] but ['1','1','1'].map(n => parseInt(n)) returns [1, 1, 1].
['1', '2', '3'].map(parseInt)
This would be a bummer to be put on-the-spot to answer. It was fun while not being in an interview though.Re: Ask HN: “Expert Level” JavaScript questions?
#25Why creating an element and afterwards setting it to invisible, will never end with a 'blinking' element.
Re: Ask HN: “Expert Level” JavaScript questions?
#26If I'm ever in a position where I'm responsible for technical interviews I'm pretty sure I'll give them open internet questions. Then ask them to talk me through their thought process. Even though questions could probably be answered by anyone with decent skills, the best will certainly stand out in how they talk you through their thought process.
Re: Ask HN: “Expert Level” JavaScript questions?
#27Explain why ['1','1','1'].map(parseInt) returns [1, NaN, 1] but ['1','1','1'].map(n => parseInt(n)) returns [1, 1, 1].
What the hell, who on earth thought that behaviour would be a good idea?
[1, 2, 3, 4].reduce((x, y) => Math.min(x, y))
should be 1 but [1, 2, 3, 4].reduce(Math.min)
should be NaN, for similar reasons. Unfortunately it's a recurring theme in JS that a lot of useful functions have optional extra parameters and a lot of useful higher order functions pass extra context to their callbacks, causing many traps for the unwary if you try to use these tools in a style that works fine in most functional programming languages.Re: Ask HN: “Expert Level” JavaScript questions?
#28But as other have already pointed out, quiz-type questions that are trivially searchable and irrelevant for practical programming tell about a culture of the company. Use that as hint if you want to work for them.
Re: Ask HN: “Expert Level” JavaScript questions?
#29You might see a dumb question that is just a bunch of spaghetti nonsense you'll have to unravel. Explain what this ridiculous codeblock does.
Definitely expect to see closure-based problems. You can almost bet your money on seeing an anonymous function in a loop printing an unexpected value of i:
(copy these code blocks into your browser console and test them out)
for(var i = 0; i
Event loop: Explain it in words or pictures. Explain why setTimeout(func, 0);
works.variable scoping with var, let and const. Variable and function hoisting. Expect brain teasers exploiting the differences in const / let and var:
const x = [1, 2, 3];
for (var i = 0; i
Scoping and binding. Function.prototype.bind(), Function.prototype.apply(), Function.prototype.call(). Maybe explain why you have to bind ES6 class methods used in callbacks.Re: Ask HN: “Expert Level” JavaScript questions?
#30Earlier quoted context omitted.
What the hell, who on earth thought that behaviour would be a good idea?
.map(fn) calls its callback with three arguments, the value, the index, and the full array. Then parseInt takes two arguments, the string and the base (radix). "1" of base 0 is 1 "1" of base 1 is NaN "1" of base 2 is 1 The gotcha here is if you map(fn), you're going to get all three arguments sent to the fn, where map(v => fn(v)) explicitly only sends the first one.