JavaScript MCQs – ES6+ Features and Functional Programming is a critical topic for interviews as it covers modern JavaScript advancements. Understanding concepts like let, const, arrow functions, promises, destructuring, and functional programming methods (map, reduce, filter) is essential. These features make code more efficient and readable. Practicing MCQs on these topics strengthens your knowledge and helps you prepare for advanced coding challenges in interviews.
1.) What does the let
keyword do in ES6?
A) Declares a variable globally
B) Declares a variable with block scope
C) Declares a constant variable
D) Declares a variable with function scope
2.) Which feature allows default values in functions?
A) Arrow functions
B) Rest parameters
C) Default parameters
D) Spread operator
3.) What does the spread operator (…) do?
A) Merges arrays into objects
B) Splits arrays into individual elements
C) Expands iterable elements into individual values
D) Declares a rest parameter
4.) How can you make a function return a promise in ES6?
A) By adding async before the function name
B) By using await inside the function
C) By calling .then() inside the function
D) By wrapping the return value in Promise.resolve()
5.) What does the const
keyword do?
A) Declares a constant variable with global scope
B) Declares a variable that cannot be reassigned
C) Declares a variable with block scope
D) Both B and C
6.) Which method is used to create a shallow copy of an array in ES6?
A) Array.copy()
B) Array.clone()
C) […array]
D) Array.prototype.copy()
7.) What does the Promise constructor accept?
A) A string argument
B) A callback function with resolve and reject parameters
C) An array of values
D) Another promise
8.) What is the use of arrow functions in ES6?
A) Declares functions with a simpler syntax
B) Declares functions with lexical this binding
C) Supports this context binding
D) All of the above
9.) Which symbol is used to create private class fields in ES6+?
A) _
B) #
C) private keyword
D) @
10.) What does the map() method do in functional programming?
A) Filters elements based on a condition
B) Transforms each array element and returns a new array
C) Mutates the original array
D) Sorts the array
Related