ES6 - Set Method clear()
This function clears all elements from the Set.
Syntax
Below mentioned syntax is for clear().
set_name.clear()
Example
<script> let names= new Set(['A','B','C','D']); console.log(names) names.clear(); console.log(names) </script>
The output of the above code is as stated below −
{"A", "B", "C", "D"}
{}
Advertisements