Live data from Hacker News

Ask HN: “Expert Level” JavaScript questions?

news.ycombinator.com

21–30 of 54 posts

Re: Ask HN: “Expert Level” JavaScript questions?

#21
post #4

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.

Imo few questions should be. I've seen some "senior" devs that was just above typical junior, still not good enough to be called a "good middle". Filtering them out as soon as possible saves some time for both parties.

Re: Ask HN: “Expert Level” JavaScript questions?

#23
Know the details around bind, 'this', dot operator, 'new', call/apply, 'in', variable hoisting, the actual data types JS provides out of the box (Longs aren't one of them) and some assortment of new features/proposed features like classes, and you'll be ahead of lots of seniors. Personally I'd appreciate a good showing in knowledge of the standard library, where its gaps/gotchas are, levels of browser support... (e.g. even IE11 supports sets -- we can use actual built-in set data structures! -- just not the full API. But it has the minimum.)

I 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?

#24

Explain why ['1','1','1'].map(parseInt) returns [1, NaN, 1] but ['1','1','1'].map(n => parseInt(n)) returns [1, 1, 1].

Hah! That's amusing. It took me a moment to realize what might be happening, and then another moment to confirm it. Another funny example is:

  ['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?

#26
I'd say these days "knowing" something is far less important than being able to "learn" something.

If 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?

#27

Explain 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?

Probably the same person who thought

    [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?

#28
I was once asked about what I would remove from JS. The following discussion touched JS linters and coding style.

But 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?

#29
There are the run-of-the mill senior level generic questions about high level knowledge and procedure. I'll ignore those since you asked specifically about expert level general JavaScript knowledge (not specific to node or front end):

You 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?

#30
post #15

Earlier 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.

I see. I'll remember this example for when someone asks why you need types.
Post reply on HN