
My list of JavaScript interview questions - bcherny
https://performancejs.com/post/hde6d32/The-Best-List-of-Frontend-JavaScript-Interview-Questions-(written-by-a-Frontend-Engineer)
======
YorickPeterse
To be honest none of these questions really give any insight into the
skills/experience of the applicant as most of them come down to just reciting
Wikipedia entries. If you want to get a better understanding of the applicant,
try asking them to solve simple problems relevant to the position instead of
performing a pop quiz.

In case of Javascript such a question could be:

    
    
        Users are reporting that page X takes a long time to load. How would you go
        about finding out why this page takes long to load and where time is being
        spent? What are the benefits and drawbacks of your approach, and what are
        the alternatives?"
    

The phrasing is just an example, but the idea is to:

1\. Propose a problem that one can solve in e.g. 5-10 minutes

2\. Ask them to think about the problem, their approach, benefits, drawbacks,
etc

3\. Have them deal with a problem that's actually relevant to the position,
giving the applicant a better taste of what it's like to work at the
organisation

~~~
bcherny
You may have missed it, but that's question #10 under "Concepts":

    
    
        My website is slow. Walk me through diagnosing and
        fixing it. What are some performance optimizations
        people use, and when should they be used?

~~~
nailer
Probably because the initial questions emphasise memorising or creating
algorithms, which is a very small part of JS development.

~~~
bcherny
"Concepts" is the 1st section..

------
donatj
Lol, I've been doing this for 11 years and doing Fibonacci off the top of my
head would make me sweat.

To me it seems a fairly unimportant exercise that proves little other than
that you know the formula for the Fibonacci sequence of the top of your head
under duress.

~~~
lj3
16 years here and I failed a fibo question a few years ago. I don't do live
coding well and it's rare to do that kind of "classic" recursion in a JS app.
I've since added it to a list of practice questions I go over before I start
interviewing, just in case somebody asks it.

~~~
keithnz
what I missed was that these are supposed to be practice questions, so while
they are sucky questions, they are question worth practice as opposed to good
questions to ask

------
jzig
I am a frontend engineer as well and would probably only be able to answer
half of those questions reasonably without studying. Sigh.

~~~
blaisio
Which questions specifically would you have trouble with?

While technically these aren't things someone absolutely has to know in order
to be useful on frontend work, I think they are all very useful and practical
things to know, so maybe you should learn about them!

~~~
jzig
The following is intentionally a little snarky.

I know what IP and DNS are but I couldn't tell you how they work.

I almost never use `this` and therefore don't remember all of its nuances. My
team specifically avoids using it because it is harder for junior devs to
grasp and makes things harder to read. I tend to agree.

Writing a reduce function? That's what I use lodash for.

What is REST? I use it every day but would have to look up a proper definition
for you.

The event loop? I know what it is but I have never needed to know what it is.

I should learn these things because they are practical? Most of them aren't at
my current job, but that's just my experience. And I probably get paid enough
and have enough day to day freedom that I wouldn't want to work for you.
However I would gladly answer all of these questions as a part of take home
"homework".

Sorry if I'm being a curmudgeon. Shrug.

P.s. your website is down!

~~~
Sohcahtoa82
> What is REST? I use it every day but would have to look up a proper
> definition for you.

REpresentation State Transfer

...

That's about all I can do to define REST. I can't really tell you what it
really means beyond describing CRUD, but I can identify a REST interface when
I see one.

~~~
eyelidlessness
REST isn't exactly aligned with CRUD, though it's often used for CRUD APIs.

REST generally describes (roughly in order of most common in implementation to
least):

\- HTTP requests operate on resources \- HTTP verbs describe the specific
operations to perform (most typically HEAD, GET, POST, PUT, DELETE; some
systems also implement OPTIONS, PATCH, custom verbs; some less-RESTful systems
use POST for everything besides GET) \- Resources have a single identifier
(URL); some systems get this wrong \- Query string parameters provide
filtering and conditional behavior on requests for resources \- HTTP status
codes indicate the condition of the response \- HTTP headers provide
mechanisms for authorization/authentication, content type negotiation,
pagination, error condition mitigation (redirects, rate limiting, etc) \-
Responses provide URLs to related resources where appropriate

I'm probably forgetting a ton. The fundamental idea behind REST is to use the
semantics of HTTP, as they were designed, to implement and interact with an
API.

~~~
Sohcahtoa82
Well damn I just got told what's up.

~~~
eyelidlessness
I wish I'd noticed how bad the formatting was on that. I don't see a way I can
edit it to fix it now.

------
jbreckmckye
I've worked as a JavaScript developer for several years, and not once have I
had need to write functions checking for palindromes, asserting prime-ness or
other such efforts in rewriting lodash.

I guess I must just be missing the job adverts for all those businesses
writing JavaScript utility libraries.

~~~
bcherny
The specific functions you're implementing aren't important. What's important
is that you can reason through a question, suggest possible algorithms, reason
about their tradeoffs, write some code, and communicate all of that to the
interviewer.

What sort of questions do you ask instead?

~~~
jbreckmckye
"What happens when I point my browser at $CANDIDATE'S_LAST_PROJECT?"

"What's your strategy for avoiding bugs?"

"How do you choose technologies?"

These three questions will prove

\- that the developer understands the technology they work with (they know
about networking, infrastructure, the server tech and are curious enough to
learn about the runtimes their apps actually live on);

\- that the developer has a mature opinion on testing (she knows what is and
isn't worth automating, and that E2E automation often has a poor ROI)

\- that the developer uses due dilligence and smart heuristics to choose
technologies ('write a prototype!', 'eyeball the open source community!')
rather than trends and groupthink ('everyone uses React!', 'someone on Medium
said it was "curated"!')

These are the real competencies to filter by. The actual programming part, in
most jobs, is easy. 80% of the roles I've interviewed candidates for have just
been extravagant excuses to move around strings and shuffle integers between
databases and browsers. I see no reason to believe this will soon change.

The last time I did anything vaguely 'algorithmic' was when I needed to sort a
few thousand items without killing IE8's UI thread, and I solved it fairly
trivially by writing a quicksort that used the recursion calls as an
opportunity to yield the event loop. That's it. That is as far as most JS jobs
go. I think anyone insisting otherwise is just being self-important.

------
andrewstuart
I ask some of these questions for assessing JavaScript:

\- what is the challenge of asynch programming in JavaScript?

\- what is your personal approach to solving the challenge of async
programming in JavaScript?

\- do you know what promises are? if yes, can you explain how promises work?

\- what is the key problem with scope and this in ES5? how do you address it?

\- have you used ES2015/ES6?

\- if candidate has ES2015 knowledge: what are the features of ES2015 that you
find most valuable?

\- if candidate has ES2015 knowledge: what is the key value of arrow
functions?

\- if you have used asynch and await, can you explain how to use them?

\- which JavaScript build tools do you use? what purpose does each of them
serve?

\- which JavaScript frameworks or libraries are you most familiar with?

\- do you use the browser developer tools? which do you use? explain the
process of using them.

\- how do you use 'inspect element' as part of your development process?

I'm not interested in questions of syntax because doesn't every programmer
spend all their time looking up syntax?

------
flanbiscuit
What kind of work would this new applicant be doing? What product does your
company make?

> What is Big O notation, and why is it useful?

Curious why you lead with this question? The rest of the top 11 questions are
very Web dev and Javascript specific so that question sticks out. If people
don't know the answer to it do you fault them for that?

~~~
bcherny
It's a basic programming and communication skill. If someone doesn't know what
it's called or what the syntax is that's fine. What's more important is the
intuition:

If I have program A:

    
    
        for (let i = 0; i < m; i++) {...}
    

And program B:

    
    
        for (let i = 0; i < m; i++) {
          for (let j = 0; j < m; j++) {...}
        }
    

Then A is more optimal than B, because A runs the loop m times, but B runs the
loop m*m times. That's it - if an engineer can reason through that, it's
enough to explain to an interviewer tradeoffs between a few possible
algorithms that solve some question.

~~~
flanbiscuit
Have you found that these questions have definitely helped you build a strong
team? Has anyone ever passed your interview questions but failed as an actual
employee? Just curious

~~~
bcherny
The "Concepts" and "Debugging" sections are very strong signals in my
experience. "Coding" is much less useful IMO, but this blog post is to help
you practice the sorts of questions that are asked in practice, rather than
what I ask specifically.

~~~
flanbiscuit
yeah i figured it was a pick and choose what fits best. Thanks for sharing
your list! These kind of interview questions get posted on HN a lot and
there's always the same reaction.

------
mnemotronic
I'm fjnorked. I wonder if McDonalds needs a whopper-flopper or cashier with 40
years of s/w development experience.

~~~
jjnoakes
If you want a job at McDonald's, you should be aware that they don't serve
whoppers :)

------
cordite
These remind me of code challenge questions that really seem to require an
emphasis on algorithmic ingenuity for tight looped code...

I often work with concurrency, data structures, and integrating with existing
code. It never seems like these challenges map to the work I do.

~~~
bcherny
If you have some good questions, I'd love to add them to the list.

------
jroseattle
Given this is a means to an end, I'd like to see the overall team hired and
the output they're responsible for creating, maintaining and extending. (I'm
assuming that's something they do.) And then, of course, the code
repositories.

------
tzs
> missing - Takes an unsorted array of unique numbers (ie. no repeats), and
> returns the missing number in the sequence (there are either no missing
> numbers, or exactly one missing number). Can you do it in O(N) time? Hint:
> There’s a clever formula you can use.
    
    
      missing([1, 4, 3])                  // 2
      missing([5, 1, 4, 2])               // 3
      missing([1, 2, 3, 4])               // undefined
    

I see some ambiguities there. Are they intentional to test the candidate? In
particular:

Is the correct result for

    
    
      missing([2,3,4])
    

undefined or 1?

What is the correct result for

    
    
      missing([])
    
    ?

~~~
bcherny
Updated, good catch.

------
keithnz
What is the DOM?

Now that I've asked that pesky question, I will not ask anything more about
the essential thing you need to manipulate as a front end engineer, what I
want to ask about is algorithms implemented in many libraries because for some
reason everyone else asks these questions in interviews.

There's a lot better questions you could potentially ask that are algorithmic
but more relevant and more approachable than mathematical functions, like text
manipulation, json manipulation.

~~~
bcherny
What are some examples? I'd be happy to add them.

~~~
keithnz
well I often start with simple things like reversing the words in a string so
"The cat sat on the mat" becomes "ehT tac no eht tam". Parse CSV into json.
Various things to show how people manage state ( write a mini game of some
sort )

------
tzs
> What is the DOM?

There is about a 50% chance I would answer "It is what values of β will give
rise to", and hope the interviewer is an old Unix hand and gets a chuckle out
of it [1].

[1] [https://www.bell-labs.com/usr/dmr/www/odd.html](https://www.bell-
labs.com/usr/dmr/www/odd.html)

------
kevinliang
I don't mean to sound arrogant in any way but just to let you know these
questions are way too easy. It's usually better to ask more open ended
questions instead of it sounding like a quiz on JavaScript fundamentals

~~~
bcherny
That's what the "Concepts" section is for. Those questions are designed so
that you can keep going deeper for people that know the concept. At some point
everyone bottoms out, but it's a different point for everyone. Eg.

    
    
        "What is the event loop?"
        "It's how JS does async"
        "How does it work?"
        "There's a stack and a queue managed by the platform"
        "How else could you design that?"
        "Other languages have threads"
        "What are the tradeoffs between evented I/O and threads?"
        "Memory safety and programmer error, CPU/memory utilization"
        ...

------
RodericDay
All those questions seem perfectly reasonable to me.

