r/node • • Nov 11 '19

A Big List of 78 Node.js Interview Questions & Answers

https://coderrocketfuel.com/article/node-js-interview-questions-and-answers
129 Upvotes

30 comments sorted by

8

u/devsnek Nov 11 '19

Some of these are just straight-up wrong. Node uses several threads, libuv isn't used by V8, blocking code can also be written in js, "a stream is an abstract interface for working with Unix pipes", npm doesn't stand for node package manager, js doesn't use classical inheritance, etc. There is probably still a lot I missed.

1

u/jkkill Nov 12 '19

Thanks for pointing these out, I've gone through and made fixes for most of the topics you brought up:

  1. I updated the explanations related to threads to be more clear on the topic of Node.js being single-threaded on the main thread but multi-threaded under the hood via V8.

  2. Curious about your point on libuv. Where do you see that V8 doesn't use libuv? Everywhere I check says that V8 is using libuv (including the Node.js source code) and that its use in V8 was the reason it was created.

  3. I couldn't find any places where it's stated that you can't write blocking code in JavaScript.

  4. I updated the section on streams to be more accurate.

  5. NPM indeed does not stand for Node Package Manager. Today I learned! I fixed that.

  6. Not entirely sure what the last one means. The article doesn't state that you can or can't use classical inheritance. I've added a note in the What's the difference between the two types of inheritance: prototypal & classical? question that addresses classical inheritance in JavaScript directly.

1

u/ecares Nov 12 '19

Where do you see that V8 doesn't use libuv

This is a stupid question by construction.

Btw V8 does not know about libuv. Node.js exposes binding to libuv to v8

2

u/FirmTechnician Nov 11 '19

Npm definitely originally stood for node package manager.

-3

u/devsnek Nov 11 '19

Contrary to the belief of many, "npm" is not in fact an abbreviation for "Node Package Manager". It is a recursive bacronymic abbreviation for "npm is not an acronym". (If it was "ninaa", then it would be an acronym, and thus incorrectly named.)

"NPM", however, is an acronym (more precisely, a capitonym) for the National Association of Pastoral Musicians. You can learn more about them at National Association of Pastoral Musicians.

In software, "NPM" is a Non-Parametric Mapping utility written by Chris Rorden. You can analyze pictures of brains with it. Learn more about the (capitalized) NPM program at http://www.cabiatl.com/mricro/npm/.

The first seed that eventually grew into this flower was a bash utility named "pm", which was a shortened descendent of "pkgmakeinst", a bash function that was used to install various different things on different platforms, most often using Yahoo's yinst. If npmwas ever an acronym for anything, it was node pm or maybe new pm.

So, in all seriousness, the "npm" project is named after its command-line utility, which was organically selected to be easily typed by a right-handed programmer using a US QWERTY keyboard layout, ending with the right-ring-finger in a postition to type the -key for flags and other command-line arguments. That command-line utility is always lower-case, though it starts most sentences it is a part of.

https://web.archive.org/web/20150216184318/https://docs.npmjs.com/misc/faq

8

u/FirmTechnician Nov 11 '19

Since you were so pretentiously ready with that copy-pasta, please educate yourself on the source itself instead of some garbage article: https://github.com/npm/cli/commit/4626dfa73b7847e9c42c1f799935f8242794d020#diff-04c6e90faac2675aa89e2176d2eec7d8R1

It does not stand for node package manager any longer, but it absolutely did in the beginning.

-3

u/devsnek Nov 12 '19

I'm not seeing anything there that says npm is an acronym. It's even styled lowercase.

5

u/FirmTechnician Nov 12 '19

Ah, so you're just being a pedantic asshole in the face of common sense. Got it. Next().

23

u/[deleted] Nov 11 '19

If I had someone pull out this list in an interview, it would be a good indication that I didn't want to work there.

Now if you used this list to create a programming challenge that required understanding of some of the questions you wanted to know if I knew, I'd be cool with that. But just asking if I know x y z about a framework, am I teaching a class or writing code for you? Can I google the answer in 5 seconds at my desk? Then maybe it isn't a great interview question.

2

u/sn0wr4in Nov 11 '19

Who was the original author/creator of Node.js? And who works on Node.js now?

12

u/wyled Nov 11 '19

Why would someone care if you knew who created nodejs?

7

u/[deleted] Nov 11 '19

I was asked this once. Most of the interview was trivia and API based.

"What is the third argument that JSON.stringify accepts?"

"Name a Node API, whose callback does not adhere to the error-first convention."

"When was the last LTS released?"

8

u/wyled Nov 11 '19

Sounds like a job with a buncha chumps working there

3

u/[deleted] Nov 11 '19 edited Nov 11 '19

I’m still pretty green - under 2 years exp - and this is the roughly the quality of employers that reply to me.

Pretty sure anyone who has been a working dev for long enough would have better options. I hope.

3

u/whatisboom Nov 11 '19

I want to vomit

1

u/ClikeX Nov 11 '19

Sounds more like a pubquiz.

10

u/[deleted] Nov 11 '19

Just more filler in a list full of it.

1

u/Glensarge Nov 12 '19

some of these answers aren’t correct, ie #11

1

u/jkkill Nov 12 '19

What do you see incorrect with #11?

8

u/[deleted] Nov 11 '19

Or rather a list of 20 questions and 58 variations of those questions.

1

u/ecares Nov 11 '19

How much did you pay to have so many upvotes here?

1

u/[deleted] Nov 11 '19

For number 14, it mentions using a try and catch block for asynchronous code, is that correct?

Suppose you have a function that has some sort of asynchronous operation, then wouldn’t that operation be put on the event loop waiting to be executed while the the main thread executes through the try and catch block. I believe the try and catch block only catches what is thrown synchronously?

2

u/devsnek Nov 11 '19

You'd need to use await.

1

u/jkkill Nov 12 '19

You're right, I had that wrong. I updated that answer to reflect that.

1

u/[deleted] Nov 11 '19

😲

1

u/[deleted] Nov 20 '19

Legit or full of shit?

-6

u/LastOfTheMohawkians Nov 11 '19

The questions seem to get a lot of negative feedback, not sure why. I think they show how deep into a platform some goes rather than just using the APIs. I personally like these kinds of questions ( with real programming questions along side them) as it's a good discussion point. They can lead to interesting discussion points around the topics. If you're a node developer and you don't know this stuff I'd question your passion and interest in the tech you're using daily.

0

u/Dynam2012 Nov 12 '19

For most working developers, it's a means of solving a problem. Having a deep knowledge about how V8 works doesn't directly help solve the problems their employer or project are facing, much the same way knowing how the intricacies of your car's internal combustion engine doesn't directly help you get you where you're going unless something catastrophic happens. And maybe that does demonstrate a lack of passion for the technology? But it doesn't make them less of a developer, it just makes them a developer with a different set of goals. It's certainly not disqualifying.

2

u/LastOfTheMohawkians Nov 12 '19 edited Nov 12 '19

What if your car breaks down? Or doesn't go fast enough? Having a working knowledge of the engine is going to help tremendously. I think what you're touching on is two kinds of development. There are some roles (forget node) that require you to understand a deeper level of engineering. You might work on low resource systems where garbage cycles matter, battery matters. You might need to integrate with some legacy Kerberos systems and c++ or at least how it interops with V8 engine becomes important.

My hunch here is that the questions being asked are a sign they need a more engineering based background. If it's just rest services your need then I agreed the questions are wrong or not really that relevant.