JavaScript From Beginner To Advanced

0% completed

Previous
Next
Quiz
How do you add a key-value pair to a map in JavaScript?
A
map.add(key, value);
B
map.set(key, value);
C
map.push(key, value);
D
map[key] = value;
Which method checks if a specific value is present in a Set?
A
set.has(value);
B
set.contains(value);
C
set.find(value);
D
set.check(value);
What will the following code output?
let myMap = new Map();
myMap.set('a', 1);
myMap.set('a', 2);
console.log(myMap.get('a'));
A
1
B
2
C
[1, 2]
D
undefined
What does the following code snippet output?
let mySet = new Set([1, 2, 2, 3, 4]);
console.log(mySet.size);
A
4
B
5
C
undefined
D
Error
Which of the following is true about both Sets and Maps in JavaScript?
Choose all correct options
Both are ordered collections.
Both allow duplicate keys.
Both are iterable using the forEach method.
Both store values in key-value pairs.

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next