Home »
MCQs
Lodash Framework Multiple-Choice Questions (MCQs)
Lodash is a JavaScript library. It provides utility functions for common programming tasks using the functional programming paradigm.
Lodash Framework MCQs: This section contains multiple-choice questions and answers on the various topics of Lodash Framework. Practice these MCQs to test and enhance your skills on Lodash Framework.
List of Lodash Framework MCQs
1. Which of the following method Divides an array into pieces of a certain size?
- _.chunk(array, size)
- _.peice(array, size)
- _.data(array, size)
- _.divide(array, size)
Answer: A) _.chunk(array, size)
Explanation:
_.chunk(array, size) method Divides an array into pieces of a certain size.
Discuss this Question
2. Which of the following method Gets rid of all false values in an array?
- _.del(array):
- _.remove(array):
- _.false(array):
- _.compact(array)
Answer: D) _.compact(array)
Explanation:
_.compact(array) method Gets rid of all false values in an array.
Discuss this Question
3. Lodash is a ____ library?
- C++
- JavaScript
- Java
- Python
Answer: B) JavaScript
Explanation:
Lodash is a JavaScript library.
Discuss this Question
4. The ____ function is used to retrieve the first entry of an array.
- _.one()
- _.fortharray()
- _.first()
Answer: C) _.first()
Explanation:
The _.first() function is used to retrieve the first entry of an array.
Discuss this Question
5. To flatten the array to one level deep, use the Lodash.flatten() function.
- Lodash.pureflatten()
- Lodash.deepflatten()
- Lodash.Oneflatten()
- Lodash.flatten()
Answer: D) Lodash.flatten()
Explanation:
To flatten the array to one level deep, use the Lodash.flatten() function.
Discuss this Question
6. The ____ method is used to return a random integer inside the function's supplied range.
- _.rand()
- _.createrandom()
- _.random()
- _.randomnumber()
Answer: C) _.random()
Explanation:
The _.random() method is used to return a random integer inside the function's supplied range.
Discuss this Question
7. The Lodash ____ method returns a numeric array.
- _.range()
- _.limit()
- _.array()
Answer: A) _.range()
Explanation:
The Lodash _.range() method returns a numeric array.
Discuss this Question
8. What will be the output of the following code?
const value = _.range(10);
console.log(value);
- [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ,10]
- [1, 2, 3, 4, 5, 6, 7, 8, 9 ,10,11]
- [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Answer: C) [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
Explanation:
The output will be the range from 0 to 9 which makes the total of 10 numbers, therefore [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] will be the output.
Discuss this Question
9. What will be the output of the following code?
const value = _.range(0, 15, 5);
console.log(value);
- [ 0, 5, 10 ]
- [ 0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ]
- [ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
- [ 0, 5, 10,15 ]
Answer: A) [ 0, 5, 10 ]
Explanation:
Following will be the output: [ 0, 5, 10 ], 15 will not be included in the range.
Discuss this Question
10. The function is called n times by ____ method.
- _.repeat()
- _.times()
- _.counter().
Answer: B) _.times()
Explanation:
The function is called n times by _.times() method
Discuss this Question
11. What will be the output of the following code?
array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let chunk1 = _.chunk(nums, 2);
console.log( chunk1);
- [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9 ] ]
- [ 0, 1 ], [ 2, 3 ], [ 4, 5 ], [ 6, 7 ], [ 8,9 ]
- [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ], [ 6, 7 ], [ 8,9 ] ]
Answer: A) [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9 ] ]
Explanation:
The following will be the output: [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9 ] ]
Discuss this Question
12. _.slice() method takes how many indexes?
- 1
- 2
- 3
Answer: B) 2
Explanation:
_.slice() method takes two indexes: starting and ending indexes.
Discuss this Question
13. In _.slice() method, the starting index is ____.
- Inclusive
- Exclusive
Answer: A) Inclusive
Explanation:
In _.slice() method, the starting index is inclusive.
Discuss this Question
14. In _.slice() method, the ending index is ____.
- Inclusive
- Exclusive
Answer: B) Exclusive
Explanation:
In _.slice() method, the ending index is exclusive.
Discuss this Question
15. What will be the output of the following code?
array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let slice1 = _.slice(nums, 3, 7);
console.log(slice1);
- [3, 4, 5, 6]
- [3, 4, 5, 6,7]
- [4, 5, 6,7]
- [3,4, 5, 6,7]
Answer: C) [4, 5, 6,7]
Explanation:
The following will be the output: [4, 5, 6,7].
Discuss this Question
16. The ____ method is used to shuffle a collection.
- _.reaarange()
- _.rotate()
- _.mix()
- _.shuffle()
Answer: D) _.shuffle()
Explanation:
The _.shuffle() method is used to shuffle a collection.
Discuss this Question
17. What are some alternatives to lodash?
- Underscore.js
- Ramda
- Rx.js
- ALL OF THE ABOVE
Answer: D) ALL OF THE ABOVE
Explanation:
Following are the alternatives of lodash:
- Underscore.js
- Ramda
- Rx.js
Discuss this Question
18. Which of the following methods Reduces an array to a single value by applying a function to each element and aggregating the result?
- _.map()
- _.reduce()
- _.filter
Answer: B) _.reduce()
Explanation:
_.reduce() method Reduces an array to a single value by applying a function to each element and aggregating the result.
Discuss this Question
19. Which of the following Lodash methods generates an object that organizes array members depending on a provided iterate function?
- _.group()
- _.groupby()
- _.reduce()
Answer: B) _.groupby()
Explanation:
_.groupby() Lodash methods generate an object that organizes array members depending on a provided iterate function.
Discuss this Question
20. Which of the following Lodash methods generates a new array by applying a function to each member of the existing array?
- _.map()
- _.reduce()
- _.filter
Answer: A) _.map()
Explanation:
_.map() Lodash methods generate a new array by applying a function to each member of the existing array.
Discuss this Question