Set delete() JavaScript JS

The JavaScript Set delete() method deletes or removes only the selected elements from the Set object.

Syntax:

setObj.delete(value)

Parameters: value: It represents the value of the specified property to be deleted.

Return: It returns true if the specified element is deleted or removed successfully otherwise, it returns false.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var jewels = new Set();
jewels.add("DIAMOND").add("GOLD").add("PLATINUM").add("SILVER");
for (let i of jewels) {
document.write(i+"<br>"); }
jewels.delete("SILVER");
document.write(jewels.size);
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com