0% found this document useful (0 votes)
6 views2 pages

Javascript Frontend Interview Answers

The document provides concise explanations of key JavaScript concepts including variable declarations (var, let, const), hoisting, closures, currying, asynchronous handling, event loop, promises, and event handling techniques. It also clarifies differences between various JavaScript features such as fetch vs axios, == vs ===, and null vs undefined. Additional topics covered include optional chaining, destructuring, and the spread operator.

Uploaded by

Anjali Sharma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Javascript Frontend Interview Answers

The document provides concise explanations of key JavaScript concepts including variable declarations (var, let, const), hoisting, closures, currying, asynchronous handling, event loop, promises, and event handling techniques. It also clarifies differences between various JavaScript features such as fetch vs axios, == vs ===, and null vs undefined. Additional topics covered include optional chaining, destructuring, and the spread operator.

Uploaded by

Anjali Sharma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Frontend Interview – Short Answers

Explain var, let, and const.


var is function-scoped and can be redeclared. let is block-scoped and can be reassigned but not
redeclared in the same scope. const is block-scoped and cannot be reassigned after declaration.

What is Hoisting?
Hoisting is JavaScript’s behavior of moving variable and function declarations to the top of their
scope during the compilation phase.

What is the Temporal Dead Zone (TDZ)?


The time between entering a block and the actual declaration of a let or const variable where the
variable cannot be accessed.

What is a Closure?
A closure is a function that remembers and can access variables from its outer scope even after the
outer function has finished executing.

What is Currying?
Currying is a technique where a function with multiple arguments is transformed into a sequence of
functions each taking one argument.

JavaScript is single-threaded, so how does it handle asynchronous tasks?


It uses the Event Loop, Web APIs, and callback queues to handle asynchronous operations without
blocking the main thread.

What is the Event Loop and how does it work?


The event loop continuously checks the call stack and task queue. If the call stack is empty, it
pushes queued tasks to the stack for execution.

What are Microtasks and Macrotasks?


Microtasks include promises and mutation observers and run before macrotasks. Macrotasks
include setTimeout, setInterval, and DOM events.

How do Promises work in JavaScript?


A Promise represents an asynchronous operation with three states: pending, fulfilled, or rejected. It
allows handling async results using .then() and .catch().

Difference between fetch and axios?


fetch is a built-in browser API for HTTP requests. axios is a third■party library that provides
additional features like automatic JSON parsing and better error handling.
Why do we use .then()?
.then() is used to handle the resolved value of a Promise after the asynchronous operation
completes.

What is Callback Hell?


A situation where multiple nested callbacks make the code difficult to read and maintain.

What is an Event Listener?


An event listener is a function that waits for a specific event (like click or submit) and executes when
that event occurs.

What is Event Bubbling?


Event bubbling is the process where an event starts from the target element and propagates
upward through its parent elements.

What is Event Delegation?


A technique where a parent element handles events for its child elements using event bubbling.

Difference between == and ===


== checks value with type conversion, while === checks both value and type without conversion.

Difference between null and undefined


undefined means a variable is declared but not assigned a value. null is an intentional assignment
representing no value.

What is Optional Chaining?


Optional chaining (?.) allows safe access to nested object properties without throwing errors if a
property is undefined.

What is Destructuring?
Destructuring is a syntax that allows extracting values from arrays or properties from objects into
variables.

What is the Spread Operator?


The spread operator (...) expands elements of an array or object, commonly used for copying or
merging data.

You might also like