1. What does the 'reduce()' method do in JavaScript?
A) Modifies the original array
B) Reduces an array to a single value
C) Filters elements based on a condition
D) None of the above
Show Explanation
2. What does the 'typeof' operator do in JavaScript?
A) Returns the data type of a variable
B) Converts a variable to a string
C) Declares a new variable
D) None of the above
Show Explanation
3. What is a first-class function in JavaScript?
A) A function that can only be called once
B) A function that is executed in a special context
C) A function that can be treated as a variable
D) None of the above
Show Explanation
4. What is the main difference between 'var' and 'let' in JavaScript?
A) 'var' is used for constants
B) 'let' has block scope, 'var' does not
C) There is no difference
D) 'var' is preferred in modern JavaScript
Show Explanation
5. What does the keyword 'this' refer to in JavaScript?
A) The global object only
B) The parent function
C) The context of the function call
D) None of the above
Show Explanation
6. What is a key feature of arrow functions in JavaScript?
A) They cannot be used as methods
B) They have their own 'arguments' object
C) They always return a promise
D) They inherit 'this' from the parent scope
Show Explanation
7. What does the 'setTimeout()' function do in JavaScript?
A) Executes a function after a delay
B) Schedules a function to run immediately
C) Repeats a function at specified intervals
D) None of the above
Show Explanation
8. What is a closure in JavaScript?
A) A way to encapsulate data
B) A function that can only be called once
C) A function that retains access to its outer function's scope
D) None of the above
Show Explanation
9. What is a promise in JavaScript?
A) A synchronous function
B) An object representing an asynchronous operation
C) A way to handle callbacks
D) None of the above
Show Explanation
10. What does the 'slice()' method do in JavaScript?
A) Returns a portion of an array
B) Modifies the original array
C) Combines two arrays
D) None of the above
Show Explanation
11. What is the difference between 'null' and 'undefined' in JavaScript?
A) They are the same
B) 'null' is a type, 'undefined' is not
C) 'null' is used for objects only
D) 'null' is an object, 'undefined' is a type
Show Explanation
12. What does the 'map()' method do in JavaScript?
A) Modifies the original array
B) Transforms each element in an array and returns a new array
C) Filters elements based on a condition
D) None of the above
Show Explanation
13. What does JSON stand for?
A) JavaScript Online Notation
B) JavaScript Object Notation Protocol
C) JavaScript Object Notation
D) None of the above
Show Explanation
14. What is an event listener in JavaScript?
A) A function that executes automatically
B) A function that waits for an event to occur
C) A method that triggers events
D) None of the above
Show Explanation
15. What does the 'async' keyword do in JavaScript?
A) Declares a constant
B) Makes a function run synchronously
C) Declares a variable
D) Allows a function to return a promise
Show Explanation
16. What does the 'filter()' method do in JavaScript?
A) Combines two arrays
B) Returns a new array with elements that pass a condition
C) Modifies the original array
D) None of the above
Show Explanation
17. What is hoisting in JavaScript?
A) A way to handle asynchronous operations
B) A method of organizing code
C) A mechanism to move declarations to the top of their scope
D) None of the above
Show Explanation
18. What is a callback function in JavaScript?
A) A function that calls itself
B) A function executed immediately
C) A function that returns a promise
D) A function passed as an argument to another function
Show Explanation
19. What does the 'reduce()' method do in JavaScript?
A) Transforms each element in an array
B) Combines two arrays
C) Reduces an array to a single value
D) None of the above
Show Explanation
20. What does the 'Promise' object do in JavaScript?
A) Represents the completion of an asynchronous operation
B) Represents a synchronous operation
C) Combines multiple promises
D) None of the above
Show Explanation