PRACTICE • LEARN • GROW
Module 4 Final Quiz: Objects & Arrays MCQs
Solve topic-wise placement questions and improve your skills.
Module 4 Final Quiz: Objects & Arrays Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What is the difference between
Array.prototype.slice() and Array.prototype.splice()?
A.
slice modifies the array in-place; splice returns a copy
B.
slice returns a shallow copy of a portion of an array (non-mutating); splice modifies the array in-place by removing/replacing elements (mutating)
C.
They are aliases for the exact same method
D.
splice can only add elements; slice can only remove elements
Explanation & Key
Correct Answer:
2
What is the output of the following array operation?
const nums = [1, 2, 3];
const res = nums.map(x => x * 2);
console.log(nums, res);
A.
[2, 4, 6] [2, 4, 6]
B.
[1, 2, 3] [2, 4, 6]
C.
[1, 2, 3] undefined
D.
[2, 4, 6] [1, 2, 3]
Explanation & Key
Correct Answer:
3
What is the output of the following reduce operation?
const items = [10, 20, 30];
const sum = items.reduce((acc, curr) => acc + curr, 5);
console.log(sum);
A.
60
B.
65
C.
50
D.
NaN
Explanation & Key
Correct Answer:
4
What is the result of destructuring with a default value and renaming?
const user = { name: 'Alice' };
const { name: userName, role = 'Guest' } = user;
console.log(userName, role);
A.
'Alice' 'Guest'
B.
'Alice' undefined
C.
undefined 'Guest'
D.
ReferenceError: name is not defined
Explanation & Key
Correct Answer:
5
What will be printed by the following array spread?
const a = [1, 2];
const b = [0, ...a, 3];
console.log(b);
A.
[0, [1, 2], 3]
B.
[0, 1, 2, 3]
C.
[1, 2, 0, 3]
D.
[[0], [1, 2], [3]]
Explanation & Key
Correct Answer:
6
What is the output of swapping variables using array destructuring?
let x = 10, y = 20;
[x, y] = [y, x];
console.log(x, y);
A.
10 20
B.
20 10
C.
undefined undefined
D.
[20, 10]
Explanation & Key
Correct Answer:
7
What does
Object.freeze(obj) do to an object?
A.
It turns the object into a string
B.
It makes the object shallowly immutable: existing properties cannot be modified, added, or deleted
C.
It deeply freezes all nested objects recursively
D.
It prevents reading properties
Explanation & Key
Correct Answer:
8
What is the output of the following spread shallow copy with nested object?
const orig = { a: 1, nested: { b: 2 } };
const copy = { ...orig };
copy.nested.b = 99;
console.log(orig.nested.b);
A.
2
B.
99
C.
undefined
D.
TypeError
Explanation & Key
Correct Answer:
9
What is the output of default sorting on numbers?
const nums = [10, 5, 20, 1];
nums.sort();
console.log(nums);
A.
[1, 5, 10, 20]
B.
[1, 10, 20, 5]
C.
[20, 10, 5, 1]
D.
[10, 5, 20, 1]
Explanation & Key
Correct Answer:
10
What does
Object.entries({ a: 1, b: 2 }) return?
A.
['a', 'b']
B.
[1, 2]
C.
[['a', 1], ['b', 2]]
D.
{ a: 1, b: 2 }
Explanation & Key
Correct Answer:
11
What is the output of this rest parameter snippet?
function test(a, ...rest) {
console.log(rest.length);
}
test(1, 2, 3, 4);
A.
4
B.
3
C.
1
D.
undefined
Explanation & Key
Correct Answer:
12
What is the result of using a dynamic key with bracket notation?
const key = 'role';
const user = { [key]: 'Admin' };
console.log(user.role);
A.
undefined
B.
'Admin'
C.
TypeError
D.
'role'
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong