0% found this document useful (0 votes)
2 views

Cracking the Javascript Interview11

The document provides essential JavaScript interview questions and answers covering topics such as data types, variable scoping, hoisting, closures, asynchronous programming, and memory management. It explains key concepts like the Event Loop, Promises, and modules, as well as techniques like event delegation and deep cloning. The content is aimed at helping candidates prepare for JavaScript interviews by understanding fundamental concepts and best practices.

Uploaded by

vikramstm0000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Cracking the Javascript Interview11

The document provides essential JavaScript interview questions and answers covering topics such as data types, variable scoping, hoisting, closures, asynchronous programming, and memory management. It explains key concepts like the Event Loop, Promises, and modules, as well as techniques like event delegation and deep cloning. The content is aimed at helping candidates prepare for JavaScript interviews by understanding fundamental concepts and best practices.

Uploaded by

vikramstm0000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CRACKING THE

JAVASCRIPT
INTERVIEW
Must-Know Questions & Answers!

@ sanuj bansal
React Fundamentals

1. What are the different data types in JavaScript?


JavaScript supports primitive types like String, Number, Boolean, Null,
Undefined, BigInt, and Symbol, as well as reference types like Objects and
Arrays.

2. What is the difference between var, let, and const?


var is function-scoped and hoisted. let and const are block-scoped. const is
used for variables that shouldn’t be reassigned.

3. What is hoisting in JavaScript?


Hoisting is JavaScript's behavior of moving variable and function
declarations to the top of their scope before code execution.

4. Explain the concept of scope in JavaScript.


Scope defines the accessibility of variables. JavaScript has function scope
and block scope (with let and const).

5.What are truthy and falsy values in JavaScript?


Truthy values evaluate to true in a boolean context, while falsy values (like 0,
null, undefined, NaN, '', and false) evaluate to false.

@ sanuj bansal
React Fundamentals

6. What is the difference between regular functions and arrow functions?


Arrow functions have a shorter syntax and do not bind their own this. They
inherit this from the surrounding context.

7. What are higher-order functions?


These are functions that take other functions as arguments or return them as
results, enabling functional programming techniques.

8. What is a closure in JavaScript?


A closure is formed when a function remembers variables from its outer
scope even after that outer function has finished executing.

9. Explain the this keyword. How does it behave in different contexts?


this refers to the object that is executing the current function. Its value
depends on how the function is called—object method, regular function,
arrow function, etc.

10. How does prototypal inheritance work in JavaScript?


Objects can inherit properties and methods from other objects via a
prototype chain, allowing shared behavior.

@ sanuj bansal
React Fundamentals

11. What is the difference between synchronous and asynchronous code?


Synchronous code executes line by line, blocking the thread. Asynchronous
code allows tasks to run in the background without blocking the main thread.

12. Explain the Event Loop in JavaScript.


The Event Loop handles asynchronous operations by managing the call stack
and the task queue, enabling non-blocking behavior.

13. What are Promises? How do they work?


Promises represent the eventual completion (or failure) of an asynchronous
operation. They have states: pending, fulfilled, or rejected.

14. What is async/await and how is it different from Promises?


async/await is syntactic sugar over Promises, making asynchronous code look
and behave more like synchronous code.

15. What is a callback function? What are callback hell and how can you
avoid it?
A callback is a function passed as an argument to another function. Callback
hell occurs when callbacks are nested deeply. It can be avoided using
Promises or async/await.

@ sanuj bansal
React Fundamentals
16. What is event delegation in JavaScript?
Event delegation is a technique where a parent element handles events for
its child elements using event bubbling.

17. What are the different ways to deep clone an object in JavaScript?
Deep cloning means creating a full copy of an object including nested
structures. This can be done using structured cloning or libraries.

18. Explain debounce and throttle functions. Where are they used?
Debounce limits how often a function is called after a delay, useful in search
input. Throttle limits function calls at regular intervals, useful in scroll or
resize events.

19. What are modules in JavaScript and how do you export/import them?
Modules are files that encapsulate code. They can export functions,
variables, or objects and import them in other files for reuse and separation
of concerns.

20. How does JavaScript handle memory management and garbage


collection?
JavaScript automatically allocates and frees memory. Garbage collection
cleans up unused objects, mainly using reference counting and mark-and-
sweep algorithms.

@ sanuj bansal
Follow For More
Such Content !

Sanuj Bansal
Senior Developer

You might also like