Hash Tables & JavaScript Objects
What optimization is missing from this delete implementation?
class HashTable {
delete(key) {
const index = this._hash(key);
if (!this.keyMap[index]) return false;
const bucket = this.keyMap[index];
const keyIndex = bucket.findIndex(item => item[0] === key);
if (keyIndex === -1) return false;
bucket.splice(keyIndex, 1);
return true;
}
}