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?
set.add(“one”);
set.add(“two”);
set.add(“three”);
set.clear();
document.writeln(set.size);

What will be the output of the following JavaScript code?
set.add(“one”);
set.add(“two”);
set.add(“three”);
set.clear();
document.writeln(set.size);
a) one
b) 1
c) 2
d) 0

Answer: d
Explanation: JavaScript Set clear() method is used to remove all the elements from Set object. The clear method will remove all the entries and hence the size of the set will be zero.

Join The Discussion