🌐 Bonus Questions:
Answer: String, Number, Boolean, Object, Undefined
What is the difference between == and === operators?
Answer: == checks for value equality, === checks for value and type equality.
Answer: var, let, const
Answer: Variables and functions are declared at the top of their scope before any code is executed.
Answer: Function declaration, function expression, arrow function
Answer: Closures are functions that have access to the outer function’s scope, even after the outer function has finished execution.
Answer: Synchronous code executes sequentially, while asynchronous code uses callbacks or promises to handle tasks that take time to complete.
Answer: Regular expressions are patterns used for matching text strings. They are commonly used for validation, parsing, and searching data.
Answer: Syntax errors, runtime errors, logic errors. Handled by try-catch blocks and window.onerror event.
Answer: Modules help to organize code, improve maintainability, and prevent namespace collisions.
Explain the concept of Promises and how they are used for asynchronous operations.
Answer: Promises are objects that represent the eventual completion (or failure) of an asynchronous operation. They are used to handle the results of asynchronous tasks and ensure code execution in the correct order.
Advantages: Improves code readability and makes it easier to manage asynchronous operations.
Disadvantages: Can be confusing for beginners and requires careful error handling.
Answer: React, Angular, Vue.js, jQuery. Strengths and weaknesses vary depending on the framework/library.
Answer: Popular testing frameworks include Jest and Mocha.
Answer: Deep copy creates a new object with new memory locations for all its properties and nested objects/arrays. Shallow copy references the same memory locations as the original object’s properties.
Answer: Allows extracting specific properties from an object and assigning them to variables.
Answer: Spread syntax (…object) expands an object into its individual properties. Rest parameters collect remaining arguments into an array.
What is the difference between arrow functions and function declarations?
Answer: Arrow functions are anonymous functions with concise syntax. Function declarations require a function name.