jskatas.org Continuously Learn JavaScript. Your Way.

Set: set.delete()

Removes an element from a set.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

set.delete() deletes an element from a set

use delete(<value>) to delete an element

  • delete() returns true when the element was found
  • and the size decreases

if nothing was deleted (no element with the given value was found)

  • returns false

undefined is a valid value in a set

  • deleting it, when it is not in the set, returns false too
  • delete() removes it, when its in the set

the value does NOT get casted

  • number 1 is different to string "1"


Announcement of this kata on twitter.