ES6 mySet.delete(key)
此函数从Set中删除指定的值。
语法
mySet.delete(key);
参数
- 键 - 要从Set中删除的元素的键
返回值
如果元素已退出并被删除,则返回true ; 否则它返回false。
例
var set = new Set();
set.add(10);
set.add(20);
set.add(30);
console.log(`Size of Set before delete() :${set.size}`);
console.log(`Set has 10 before delete() :${set.has(10)}`);
set.delete(10)
console.log(`Size of Set after delete() :${set.size}`);
console.log(`Set has 10 after delete() :${set.has(10)}`)
输出
Size of Set before delete() :3
Set has 10 before delete() :true
Size of Set after delete() :2
Set has 10 after delete() :false
返回一个新的Iterator对象,该对象包含Set中每个元素的[value,value]数组。语法mySet.entries()返回值返回一个新的迭代器对象。例var mySet = new Set( ...