Top Interview Questions for Backend Developers(Node)

Introduction

Being a Full Stack Developer, I had appeared for Backend Developer position as well. In this post, I will be sharing most common Backend Dev question asked to me in all those interviews except the DSA part.

Q1. Create …


This content originally appeared on DEV Community and was authored by Abhishek Raj

Introduction

Being a Full Stack Developer, I had appeared for Backend Developer position as well. In this post, I will be sharing most common Backend Dev question asked to me in all those interviews except the DSA part.

Q1. Create a sleep function using Async/Await.

In the below example, the sleep function returns a promise which is resolved after given millisecond using setTimeout API.

Q2. How Javascript Engine works?

When a js file is ran,

  1. A global execution context is created.

  2. A memory heap is created where all variables (with var keyword) and functions (except arrow func) are declared.

    In the below image we can see, variable a is declared w/o even execution has started.
    image

  3. A Call Stack is created which stores the line which is going to be executed.
    image

  4. When call stack gets a function call, it creates a functional context and the process is repeated in the functional context.

  5. When call stack encounters WEB APIs like setTimeout/Interval/Immediate, these are sent to callback queue to process after call stack is empty.

  6. When call stack encounters a Promise it is sent to micro task queue (higher priority than callback queue) to process after call stack is empty.

  7. Once call stack is empty, event loop moves functions from queues to call stack for execution.

Q3. Difference between Single Threaded & Asynchronous.

My View:
Single Threaded -> It means only once function can be executed at a time.
Async -> It is about non-blocking of execution of functions.

In this below image, we can easily understand the difference. Thanks to Baeldung

image

image

Read More

Q4. How to debug a slow API?

My View:

The Console.log approach

  1. Check if the issue is with network by sending request from different network.
  2. Log time when req is received by the backend.
  3. Log time before a DB query.
  4. Log time after a DB query.
  5. Log time before/after some heavy operation.
  6. Log time before sending response.
  7. Analyse the time, you will get your culprit.

Profiler Approach

Use any profiling tool to check where the execution is lagging.

What is EventEmitter in NodeJS?

My View: EventEmitter is used to create event listeners in JS.

Read More:

Connect Me @ Linkedin, Github, Twitter, Youtube ?


This content originally appeared on DEV Community and was authored by Abhishek Raj


Print Share Comment Cite Upload Translate Updates
APA

Abhishek Raj | Sciencx (2021-08-07T17:18:29+00:00) Top Interview Questions for Backend Developers(Node). Retrieved from https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/

MLA
" » Top Interview Questions for Backend Developers(Node)." Abhishek Raj | Sciencx - Saturday August 7, 2021, https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/
HARVARD
Abhishek Raj | Sciencx Saturday August 7, 2021 » Top Interview Questions for Backend Developers(Node)., viewed ,<https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/>
VANCOUVER
Abhishek Raj | Sciencx - » Top Interview Questions for Backend Developers(Node). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/
CHICAGO
" » Top Interview Questions for Backend Developers(Node)." Abhishek Raj | Sciencx - Accessed . https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/
IEEE
" » Top Interview Questions for Backend Developers(Node)." Abhishek Raj | Sciencx [Online]. Available: https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/. [Accessed: ]
rf:citation
» Top Interview Questions for Backend Developers(Node) | Abhishek Raj | Sciencx | https://www.scien.cx/2021/08/07/top-interview-questions-for-backend-developersnode/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.