What will be the output of the following JavaScript code? [code] set.add("AngularJS"); set.add("Bootstrap"); set.delete("Bootstrap");

What will be the output of the following JavaScript code?
Code:
set.add("AngularJS");  
set.add("Bootstrap");    
set.delete("Bootstrap");  
document.writeln(set.size);
A. 2
B. 1
C. 0
D. Undefined
 
Answer: b
Explanation: The delete() method is used to remove all the elements from the Set object which are passed as an argument to the delete function. Since the delete function is called once the size will be reduced to 1.
 

Tìm kiếm

Back
Top