Q1: What is garbage collection in JavaScript?
Ans: The process of freeing up memory that is no longer being used by a program
Q2:What is the difference between synchronous and asynchronous code execution in JavaScript?
Ans: Synchronous code execution means that the code is executed in a sequential order, while asynchronous code execution means that the code is executed without waiting for the previous line to complete.
Q3:What is the event loop in JavaScript?
Ans: A mechanism that allows asynchronous code to be executed in JavaScript.
Q4:What is the difference between setTimeout and setInterval in JavaScript?
Ans: setTimeout executes a function once after a specified deley, while setInterval executes a function repeatedly at a specified interval.
Q5:How do you cancel a setTimeout or setInterval in JavaScript?
Ans: Use the clearTimeout or clearInterval method to cancel the timer
Q6:What is a Promise in JavaScript?
Ans: An object that represents a value that may not be available yet, but will be resolved or rejected in the future.
Q7:Can you use await outside of an async function?
Ans: No, await can only be used inside an async function.
Q8:What is the event loop in JavaScript?
Ans: A loop that runs events sequentially on a single thread.
Q9:What is the main difference between synchronous and asynchronous programming?
Ans: Synchronous programming executes code sequentially, while asynchronous programming does not.
Q10: Which of the following is an example of a JavaScript runtime error?
Ans: An error caused by trying to divide by zero