feat(chapter_hashing): Add js and ts codes for chapter hashing (#675)

* refactor(chapter_hashing): Remove unnecessary chaining operator

* feat(chapter_hashing): Add js and ts codes for chapter 6

* refactor(chapter_hashing): Optimize the remove function logic

* refactor(chapter_hashing): Remove unnecessary chaining operator

* refactor(chapter_hashing): use const instead of let
This commit is contained in:
William Yuan
2023-08-10 23:04:41 +08:00
committed by GitHub
parent 6ef4dc6444
commit e97eee0e18
8 changed files with 740 additions and 4 deletions

View File

@@ -62,7 +62,7 @@ class ArrayHashMap {
let arr = [];
for (let i = 0; i < this.#buckets.length; i++) {
if (this.#buckets[i]) {
arr.push(this.#buckets[i]?.key);
arr.push(this.#buckets[i].key);
}
}
return arr;
@@ -73,7 +73,7 @@ class ArrayHashMap {
let arr = [];
for (let i = 0; i < this.#buckets.length; i++) {
if (this.#buckets[i]) {
arr.push(this.#buckets[i]?.val);
arr.push(this.#buckets[i].val);
}
}
return arr;