Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
var set = new Set();
set.add(“one”);
set.add(“two”);
for (let elements of set)
{
document.writeln(elements+” “);
}

What will be the output of the following JavaScript code?
var set = new Set();
set.add(“one”);
set.add(“two”);
for (let elements of set)
{
document.writeln(elements+” “);
}
a) one
b) two
c) one two
d) undefined

Answer: c
Explanation: The JavaScript Set add() method is used to add an element to Set object with a specified value. Each element must have a unique value.

Join The Discussion