JS: Set.prototype.clear

By Xah Lee. Date: . Last updated: .

(new in JS: ECMAScript 2015)

mySet.clear()
  • Delete all values of the set mySet.
  • Return undefined.
const xx = new Set([3, 4, 5]);
console.log(xx.clear() === undefined);
console.log(xx.size === 0);

JS Set, Size Add Remove