Python Developer Interview Questions (Part 2): Multithreading, Async, FastAPI, Django and Flask
Python interview questions for 2–4 years: multithreading, multiprocessing, asyncio, FastAPI, Django, Flask and real scenarios, with code and real output.
Thirty JavaScript interview questions answered — closures, hoisting, this, promises, async/await, event loop and ES6 features — with examples.
JavaScript is the backbone of modern web development and one of the most widely used programming languages in the world. From interactive websites and single-page applications to backend services, mobile apps, and desktop applications, JavaScript powers countless technologies used every day.
Whether you're preparing for a Frontend Developer, Full Stack Developer, React Developer, Angular Developer, Node.js Developer, or Software Engineer interview, JavaScript remains one of the most important skills recruiters evaluate during technical interviews.
Interviewers frequently ask questions about variables, scope, closures, promises, asynchronous programming, event loop, ES6 features, DOM manipulation, and advanced JavaScript concepts. A strong understanding of these topics is essential for cracking modern development interviews.
In this comprehensive guide, we'll cover the Top 30 JavaScript Interview Questions and Answers that are commonly asked in technical interviews. Each question includes detailed explanations, practical examples, and interview tips to help you build confidence and strengthen your JavaScript fundamentals.
JavaScript is a high-level, interpreted programming language primarily used to create dynamic and interactive web applications. It enables developers to add functionality such as form validation, animations, API calls, real-time updates, and user interactions directly within web browsers.
Today, JavaScript is not limited to browsers. With technologies like Node.js, developers can build backend applications, APIs, microservices, desktop applications, and even mobile apps using JavaScript.
JavaScript is a versatile programming language used for building interactive web applications, backend services, mobile apps, and modern software solutions.
| Reason | Benefit |
|---|---|
| High Demand | Required for most web development jobs |
| Frontend Development | Powers React, Angular, Vue and other frameworks |
| Backend Development | Node.js enables server-side JavaScript |
| Cross Platform | Build web, mobile and desktop applications |
| Large Community | Extensive learning resources and support |
| Continuous Growth | New features introduced regularly |
| Feature | Details |
|---|---|
| Language | JavaScript |
| Type | High-Level Programming Language |
| Paradigm | Object-Oriented, Functional, Event-Driven |
| Execution | Browser and Server (Node.js) |
| Typing | Dynamically Typed |
| Latest Standard | ECMAScript (ES6+) |
| Primary Usage | Web Development |
| Popular Frameworks | React, Angular, Vue, Next.js |
| Section | Topics Covered |
|---|---|
| Q1 – Q10 | JavaScript Fundamentals |
| Q11 – Q20 | Closures, Promises, Async/Await, Event Loop |
| Q21 – Q30 | Advanced JavaScript Concepts and ES6 Features |
Part 1: JavaScript Fundamentals (Q1–Q10)
Part 2: Intermediate JavaScript (Q11–Q20)
Part 3: Advanced JavaScript (Q21–Q30)
Most JavaScript interviews focus on understanding concepts rather than memorizing definitions. Make sure you understand how JavaScript works internally, especially topics like hoisting, closures, promises, event loop, scope, and asynchronous programming.
Let's begin with the most frequently asked JavaScript interview questions that every developer should know before attending technical interviews.
Variables, Data Types, Hoisting, Scope, Functions, Arrow Functions, and Template Literals.
Answer
JavaScript is a high-level, interpreted programming language used to create dynamic and interactive web applications. It allows developers to add functionality such as form validation, animations, event handling, API communication, and real-time updates to websites.
JavaScript runs directly inside web browsers and can also be used on the server side with Node.js.
JavaScript is a versatile programming language used for frontend, backend, mobile, and desktop application development.
Example
console.log("Hello JavaScript!");
Output
Hello JavaScript!
Answer
var, let, and const are used to declare variables in JavaScript.
| Feature | var | let | const |
|---|---|---|---|
| Scope | Function Scope | Block Scope | Block Scope |
| Redeclaration | Allowed | Not Allowed | Not Allowed |
| Reassignment | Allowed | Allowed | Not Allowed |
| Hoisting | Yes | Yes (TDZ) | Yes (TDZ) |
Example
var city = "Delhi";
let age = 25;
const country = "India";
Use const by default and let when reassignment is needed. Avoid using var in modern JavaScript.
Answer
Hoisting is JavaScript's default behavior of moving variable and function declarations to the top of their scope before code execution.
Example with var
console.log(name);
var name = "Samir";
Output
undefined
Internally JavaScript interprets it as:
var name;
console.log(name);
name = "Samir";
Function Hoisting
greet();
function greet() {
console.log("Hello");
}
Hoisting is one of the most commonly asked JavaScript interview questions.
Answer
Scope determines where variables can be accessed within a program.
Types of Scope
Global Scope Example
let company = "LearnFrenzy";
function showCompany() {
console.log(company);
}
Block Scope Example
if (true) {
let age = 25;
console.log(age);
}
Outside the block, age is not accessible.
| Scope Type | Accessible Where? |
|---|---|
| Global | Entire Program |
| Function | Inside Function Only |
| Block | Inside Block Only |
Answer
Primitive data types store single values and are immutable.
JavaScript Primitive Types
Example
let name = "Samir";
let age = 25;
let isActive = true;
let salary = null;
let city;
Answer
Type Coercion is the automatic conversion of one data type into another by JavaScript.
Example
console.log("5" + 2);
Output
52
JavaScript converts number 2 into string "2" and concatenates both values.
Another Example
console.log("10" - 5);
Output
5
Understanding Type Coercion helps avoid unexpected bugs in JavaScript applications.
Answer
Both operators are used for comparison, but they behave differently.
| Operator | Description |
|---|---|
| == | Checks Value Only |
| === | Checks Value and Type |
Example
console.log(5 == "5");
Output
true
Strict Equality
console.log(5 === "5");
Output
false
Always prefer === and !== to avoid unexpected type conversions.
Answer
Functions are reusable blocks of code designed to perform a specific task.
Function Declaration
function greet() {
console.log("Hello");
}
Function Call
greet();
Output
Hello
Function with Parameters
function add(a, b) {
return a + b;
}
console.log(add(10, 20));
Answer
Arrow Functions were introduced in ES6 as a shorter syntax for writing functions.
Traditional Function
function add(a, b) {
return a + b;
}
Arrow Function
const add = (a, b) => {
return a + b;
};
Short Form
const add = (a, b) => a + b;
Arrow functions do not have their own this keyword.
Answer
Template Literals provide an easy way to create strings with embedded expressions using backticks (`).
Traditional Concatenation
const name = "Samir";
console.log(
"Hello " + name
);
Template Literal
const name = "Samir";
console.log(
`Hello ${name}`
);
Output
Hello John
Multi-line String
const message = `
Welcome
to
LearnFrenzy
`;
Closures, Callback Functions, Callback Hell, Promises, Async/Await, Event Loop, this Keyword, Higher Order Functions, Map, Filter & Reduce.
Answer
A Closure is a function that remembers and can access variables from its outer scope even after the outer function has finished executing.
Closures are commonly used for data encapsulation, private variables, event handlers, and callbacks.
Example
function outer() {
let counter = 0;
return function inner() {
counter++;
console.log(counter);
};
}
const increment = outer();
increment();
increment();
increment();
Output
1
2
3
Closures are among the most frequently asked JavaScript interview questions.
Answer
A Callback Function is a function passed as an argument to another function and executed later.
Callbacks are heavily used in asynchronous programming.
Example
function greet(name, callback) {
console.log(
`Hello ${name}`
);
callback();
}
function sayBye() {
console.log("Goodbye!");
}
greet("Samir", sayBye);
Output
Hello Samir
Goodbye!
A callback is simply a function executed after another function completes its task.
Answer
Callback Hell occurs when multiple nested callbacks make code difficult to read, maintain, and debug.
Example
getUser(function(user) {
getOrders(user.id,
function(orders) {
getPayment(
orders.id,
function(payment) {
console.log(payment);
});
});
});
The code becomes deeply nested and hard to understand.
Solutions
Callback Hell is one of the main reasons Promises were introduced in JavaScript.
Answer
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
Promise States
Example
const promise =
new Promise((resolve, reject) => {
let success = true;
if(success) {
resolve("Success");
} else {
reject("Failed");
}
});
promise
.then(result => {
console.log(result);
})
.catch(error => {
console.log(error);
});
Output
Success
Answer
Async/Await is a modern way of handling asynchronous operations that makes code easier to read and maintain.
async
Declares a function that returns a Promise.
await
Pauses execution until a Promise resolves.
Example
async function fetchData() {
const response =
await fetch("/api/users");
const data =
await response.json();
console.log(data);
}
Use Async/Await instead of deeply nested Promise chains whenever possible.
Answer
JavaScript is a single-threaded language, but it can perform asynchronous operations using the Event Loop.
The Event Loop continuously checks:
When the Call Stack becomes empty, tasks from queues are pushed into the stack for execution.
Example
console.log("Start");
setTimeout(() => {
console.log("Timer");
}, 0);
console.log("End");
Output
Start
End
Timer
Understanding the Event Loop is essential for advanced JavaScript interviews.
Answer
setTimeout() executes a function after a specified delay.
Syntax
setTimeout(
callback,
delay
);
Example
setTimeout(() => {
console.log(
"Executed after 2 seconds"
);
}, 2000);
The callback executes after approximately 2000 milliseconds.
Cancel Timeout
const timer =
setTimeout(() => {
console.log("Run");
}, 5000);
clearTimeout(timer);
Answer
The this keyword refers to the object that is currently executing the function.
Its value depends on how the function is called.
Example
const person = {
name: "Samir",
greet() {
console.log(
this.name
);
}
};
person.greet();
Output
Samir
| Context | Value of this |
|---|---|
| Global | window (Browser) |
| Object Method | Current Object |
| Arrow Function | Lexical this |
Answer
A Higher Order Function is a function that:
Example
function calculate(a, b, operation) {
return operation(a, b);
}
function add(x, y) {
return x + y;
}
console.log(
calculate(10, 20, add)
);
Output
30
Common Higher Order Functions:
Answer
These are powerful array methods used in modern JavaScript development.
| Method | Purpose |
|---|---|
| map() | Transform Array Elements |
| filter() | Filter Array Elements |
| reduce() | Reduce Array to Single Value |
map() Example
const nums =
[1, 2, 3];
const doubled =
nums.map(
num => num * 2
);
console.log(doubled);
Output
[2, 4, 6]
filter() Example
const nums =
[1, 2, 3, 4];
const even =
nums.filter(
num => num % 2 === 0
);
console.log(even);
Output
[2, 4]
reduce() Example
const nums =
[1, 2, 3, 4];
const sum =
nums.reduce(
(acc, curr) =>
acc + curr,
0
);
console.log(sum);
Output
10
Prototype, Event Delegation, Debouncing, Throttling, Currying, Memoization, Destructuring, Modules, ES6 Features, and Advanced JavaScript Concepts.
Answer
JavaScript is a prototype-based language. Every object in JavaScript has access to another object called its prototype, from which it can inherit properties and methods.
Prototypes enable inheritance in JavaScript.
Example
function Person(name) {
this.name = name;
}
Person.prototype.greet =
function() {
console.log(
`Hello ${this.name}`
);
};
const user =
new Person("Samir");
user.greet();
Output
Hello Samir
Classes in JavaScript are built on top of prototypes.
Answer
Both are used for inheritance, but Classes provide a cleaner syntax over JavaScript's prototype system.
| Prototype | Class |
|---|---|
| Prototype-Based | Syntactic Sugar |
| Older Approach | Introduced in ES6 |
| Less Readable | More Readable |
| Direct Inheritance | Class Syntax |
Class Example
class Person {
constructor(name) {
this.name = name;
}
greet() {
console.log(
`Hello ${this.name}`
);
}
}
const user =
new Person("Samir");
user.greet();
Answer
Event Delegation is a technique where a parent element handles events for its child elements using event bubbling.
Instead of attaching event listeners to multiple child elements, a single listener is attached to the parent.
Example
document
.getElementById("list")
.addEventListener(
"click",
function(event) {
console.log(
event.target.textContent
);
});
Benefits
Answer
Debouncing limits how often a function executes by delaying execution until a specified time has passed since the last event.
Commonly used for:
Example
function debounce(
fn,
delay
) {
let timer;
return function() {
clearTimeout(timer);
timer =
setTimeout(
fn,
delay
);
};
}
Wait until the user stops typing before making an API call.
Answer
Throttling limits the number of times a function can execute within a specified interval.
Unlike Debouncing, Throttling ensures execution occurs at regular intervals.
Example
function throttle(
fn,
delay
) {
let waiting = false;
return function() {
if(!waiting) {
fn();
waiting = true;
setTimeout(() => {
waiting = false;
}, delay);
}
};
}
Common Uses
Answer
Currying is a technique where a function with multiple arguments is transformed into a sequence of functions, each taking one argument.
Example
function multiply(a) {
return function(b) {
return a * b;
};
}
const double =
multiply(2);
console.log(
double(5)
);
Output
10
Currying improves code reusability and functional programming practices.
Answer
Memoization is an optimization technique that stores the results of expensive function calls and returns cached results when the same inputs occur again.
Example
const cache = {};
function square(num) {
if(cache[num]) {
return cache[num];
}
cache[num] =
num * num;
return cache[num];
}
Memoization improves performance by avoiding repeated calculations.
Expensive calculations, API responses, and data processing.
Answer
Destructuring allows extracting values from arrays and objects into individual variables.
Object Destructuring
const user = {
name: "Samir",
age: 25
};
const {
name,
age
} = user;
console.log(name);
Array Destructuring
const colors =
["Red", "Blue"];
const [
first,
second
] = colors;
Destructuring makes code cleaner and easier to read.
Answer
Modules allow developers to split code into reusable files and export functionality between files.
Export Example
export function greet() {
console.log("Hello");
}
Import Example
import {
greet
}
from "./app.js";
greet();
Benefits
Answer
ES6 (ECMAScript 2015) introduced several powerful features that modern JavaScript developers use daily.
| Feature | Description |
|---|---|
| let & const | Block Scoped Variables |
| Arrow Functions | Short Function Syntax |
| Template Literals | String Interpolation |
| Destructuring | Extract Values Easily |
| Default Parameters | Default Function Values |
| Spread Operator | Expand Arrays & Objects |
| Rest Operator | Collect Remaining Values |
| Promises | Async Programming |
| Classes | Object-Oriented Syntax |
| Modules | Import & Export Code |
Spread Operator Example
const nums =
[1, 2, 3];
const allNums =
[...nums, 4, 5];
console.log(allNums);
Output
[1, 2, 3, 4, 5]
ES6 features are heavily used in React, Angular, Node.js, and modern JavaScript development.
JavaScript remains the foundation of modern web development. Whether you're working with React, Angular, Vue, Node.js, Express.js, Next.js, or any modern framework, a strong understanding of JavaScript fundamentals and advanced concepts is essential.
Focus on mastering closures, promises, asynchronous programming, event loop, prototypes, and ES6 features, as these topics are frequently tested in technical interviews and used daily in real-world applications.
In this guide, we explored the Top 30 JavaScript Interview Questions & Answers covering beginner, intermediate, and advanced concepts. These questions are commonly asked in Frontend Developer, Full Stack Developer, Software Engineer, React Developer, Angular Developer, and Node.js Developer interviews.
Keep practicing coding challenges, building projects, and exploring JavaScript internals to strengthen your problem-solving skills and become a confident JavaScript developer.
Happy Learning and Best of Luck for Your Interviews! 🚀
One short email when we publish something new — interview questions, Salesforce guides and career tips. No spam, unsubscribe in one click.
Python interview questions for 2–4 years: multithreading, multiprocessing, asyncio, FastAPI, Django, Flask and real scenarios, with code and real output.
Python developer interview questions for 2–4 years experience with real code and output: core Python, OOP, decorators and 15 coding problems.
Agentforce interview questions for Python developers (2–4 years): Apex actions, Agentforce Python SDK, Agent API, Azure AI and real scenarios, with code.
Questions, corrections or your own experience — they all help the next reader.