The return statement in line 14, Returns from the function or it just return from the if condition? and how javascript return works?
HashTable.prototype.insert = function(key, value) {
var index = this.hash(key);
if (!this.buckets[index]) {
this.buckets[index] = new HashNode(key, value);
}
else if (this.buckets[index].key === key) {
this.buckets[index].value = value;
}
else {
var currentNode = this.buckets[index];
while (currentNode.next) {
//updaton part
if (currentNode.next.key === key) {
currentNode.next.value = value;
return;
}
currentNode = currentNode.next;// to determine last node
}
currentNode.next = new HashNode(key, value);
}
};