Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
17 views

JavaScript mulakat - interview Questions

This document contains a comprehensive list of the top 50 most asked JavaScript interview questions along with their answers. Topics covered include JavaScript fundamentals, data types, asynchronous programming, and various functions and methods. It serves as a valuable resource for developers preparing for JavaScript-related interviews.

Uploaded by

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

JavaScript mulakat - interview Questions

This document contains a comprehensive list of the top 50 most asked JavaScript interview questions along with their answers. Topics covered include JavaScript fundamentals, data types, asynchronous programming, and various functions and methods. It serves as a valuable resource for developers preparing for JavaScript-related interviews.

Uploaded by

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

JavaScript

Interview Questions
With Answers

Made by:
Want More?
DEVELOPERS Join Telegram
<SOCIETY/> Tap here
or Search on Telegram
Top 50 Most Asked

1. What is JavaScript?
JavaScript is a high-level, interpreted programming
language that conforms to the ECMAScript specification.
It is used to create interactive effects within web browsers.

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


var: Function-scoped, can be re-declared and updated.
let: Block-scoped, can be updated but not re-declared
within the same scope.
const: Block-scoped, cannot be updated or re-declared

3. What are JavaScript data types?


Primitive types: String, Number, Boolean, Null,
Undefined, Symbol, BigInt.
Object types: Object, Array, Function, etc.

4. Explain hoisting in JavaScript.


Hoisting is a JavaScript mechanism where variables and
function declarations are moved to the top of their
containing scope during the compile phase.

5. What is closure in JavaScript?

A closure is a function that retains access to its


lexical scope, even when the function is executed
outside that scope.
6. What are callbacks in JavaScript?
A callback is a function passed as an argument to
another function, which is then invoked inside the outer
function to complete some kind of routine or action.

7. What is the difference between == and ===?


== checks for value equality with type coercion.
=== checks for both value and type equality
without type coercion.

8. What is an Immediately Invoked Function Expression (IIFE)?

An IIFE is a function that is executed immediately


after it is defined. It is used to avoid polluting the
global scope.

9. What is the event loop in JavaScript?

The event loop is a mechanism that allows JavaScript to


perform non-blocking, asynchronous operations by
managing the execution of code, events, and callbacks.

10. Explain the concept of promises in JavaScript.

A promise is an object representing the eventual


completion or failure of an asynchronous operation. It
has three states: pending, fulfilled, and rejected.

11. What are arrow functions?


Arrow functions are a concise syntax for writing function
expressions. They do not have their own this context and
cannot be used as constructors.

12. What is the this keyword in JavaScript?


this refers to the context in which a function is executed.
It can refer to an object, a global object, or undefined in
strict mode.

13. What are higher-order functions?


Higher-order functions are functions that can take other
functions as arguments and/or return functions as their
result.
13. What are higher-order functions?
Higher-order functions are functions that can take other
functions as arguments and/or return functions as their
result.

14. What is async/await in JavaScript?


async/await is syntax for handling asynchronous
operations. async makes a function return a promise, and
await pauses the execution until the promise is resolved.

15. What is destructuring in JavaScript?


Destructuring is a syntax for extracting values from
arrays or objects and assigning them to variables.

16. What is the spread operator (...)?


The spread operator is used to expand elements of an
array or object. It can be used in function arguments,
array literals, and object literals.

17. What is the rest parameter (...)?


The rest parameter syntax allows a function to accept an
indefinite number of arguments as an array.

18. What is the difference between null and undefined?


undefined means a variable has been declared but not
assigned a value. null is an assignment value that
represents no value or no object.

19. What is prototypal inheritance?


Prototypal inheritance is a feature where objects inherit
properties and methods from other objects. In JavaScript,
this is achieved using prototypes.

20. What is NaN?


NaN stands for Not-a-Number. It is a value representing a
computational error or an invalid number.

21. What is the difference between call and apply?

Both call and apply invoke a function with a specified


this context. call takes arguments individually, while
apply takes arguments as an array
22. What is bind in JavaScript?
bind creates a new function that, when called, has its
this keyword set to the provided value, with a given
sequence of arguments preceding any provided when
the new function is called.

23. What is a promise chain?

A promise chain is a sequence of asynchronous


operations performed using promises where each
operation starts after the previous one is completed.

24. What is a generator function?


A generator function is a function that can stop its
execution midway and then resume from where it
stopped. It uses the function* syntax and yield keyword.

25. What is localStorage in JavaScript?


localStorage is a web storage object that allows storage
of key-value pairs in the browser with no expiration
time.

26. What is sessionStorage in JavaScript?


sessionStorage is a web storage object that stores data
for one session. The data is deleted when the browser tab
is closed.

27. What are JavaScript modules?


JavaScript modules are reusable pieces of code that
can be exported from one script and imported for use
in another. They help in organizing and managing
code.

28. What is event delegation?


Event delegation is a technique for handling events by
leveraging the event bubbling mechanism. Instead of
attaching event handlers to individual elements, an event
handler is attached to a parent element.

29. What is a polyfill in JavaScript?


A polyfill is code that provides modern functionality on
older browsers that do not natively support it.
30. What is the difference between synchronous
and asynchronous code?
Synchronous code is executed sequentially, blocking
further execution until the current operation completes.
Asynchronous code is executed concurrently, allowing
other operations to continue before the current
operation completes.

31. What is a pure function?


A pure function is a function that produces the same
output for the same inputs and has no side effects.

32. What is memoization in JavaScript?


Memoization is an optimization technique where the
results of expensive function calls are cached and
returned when the same inputs occur again.

33. What is the use of JSON.stringify and JSON.parse?

JSON.stringify converts a JavaScript object into a


JSON string. JSON.parse converts a JSON string back
into a JavaScript object.

34. What is the difference between slice and splice?


slice returns a shallow copy of a portion of an array into
a new array without modifying the original array. splice
changes the contents of an array by removing,
replacing, or adding elements.

35. What are template literals in JavaScript?


Template literals are string literals allowing embedded
expressions, denoted by backticks (`). They can contain
placeholders for variables or expressions.

36. What is the DOM?

The Document Object Model (DOM) is a programming


interface for web documents. It represents the page
structure as a tree of objects that can be manipulated
with JavaScript.
37. What is the difference between == and Object.is()?

== checks for equality with type coercion. Object.is()


checks for strict equality without type coercion, similar
to
===, but also properly handles edge cases like NaN and
-0.
38. What are JavaScript frameworks?

JavaScript frameworks are libraries that provide a


structure for building web applications, such as
React, Angular, and Vue.js.

39. What is debouncing?

Debouncing is a technique used to limit the rate at


which a function is executed. It ensures that a function
is only called after a specified delay has elapsed since
the last call.
40. What is throttling?

Throttling is a technique that ensures a function is


called at most once in a specified period. It controls the
execution rate of a function.

41. What is the difference between map and forEach?


map creates a new array by applying a function to each
element of an array. forEach executes a function for each
element without creating a new array.
42. What is a web worker in JavaScript?
A web worker is a script that runs in the background,
independently of the main browser thread, allowing for
parallel execution.

43. What is a service worker?

A service worker is a script that runs in the


background and enables features like push
notifications, background sync, and offline caching.
44. What is the fetch API?

The fetch API is a modern interface for making HTTP


requests to servers. It returns promises and is more
powerful and flexible than the older XMLHttpRequest.
45. What is CORS?
Cross-Origin Resource Sharing (CORS) is a security
feature that allows or restricts resources on a web page
to be requested from another domain outside the domain
from which the resource originated.

46. What is an event listener?

An event listener is a procedure or function in a computer


program that waits for an event to occur.

47. What is Promise.all?

Promise.all is a method that takes an array of promises


and returns a single promise that resolves when all the
promises in the array have resolved or rejects when any
of the promises reject.

48. What is the difference between window and document in


JavaScript?
window is the global object representing the browser
window. document is a property of window that represents
the DOM and provides methods to interact with the
content of the page.

49. What is the reduce method in JavaScript?


The reduce method executes a reducer function on each
element of an array, resulting in a single output value.

50. What is Object.assign?

Object.assign is a method used to copy the values of all


enumerable own properties from one or more source
objects to a target object

You might also like