MCQ
Single Best Answer
Difficult
QWhat is the result of the following code?
var set = new Set();
set.add(1);
set.add(2);
console.log(set.has(2));
ID: #4905
Javascript Data Types MCQ
204 views
Question Info
#4905Q ID
DifficultDifficulty
Javascript Data Types MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option A
Explanation
The Set data type in JavaScript is a constructor that creates a new set object, which is a collection of unique values.
The add method is used to add a new value to the set object.
The has method is used to determine whether the set object includes the specified value.
In this case, two values are added to the set object using the add method.
The has method is called on the set object, with the value 2 as the argument.
Since the set object includes the value 2, the has method will return true.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic