I think it's interesting to learn how data structures work under the hood, but for practical code, Javascript (and almost all programming languages) already have this natively implemented with objects and Map, and you're not going to beat the performance and security of V8 with js code.
With 11 years in Front-End Dev, I'm skilled in JavaScript, React, Redux, and TypeScript. I'm passionate about learning and Sharing knowledge Let's grow together!
True, totally true,
It is just like we are writing sorting algorithm for our own practice. as Javascript's sorting algorithm even better in compare to QuickSort.
So Here I am not challenging to V8, as they are written in c++, 😊.
I fail to see the reasoning of using HashMaps in js. You obtain the same behaviour of having stored a value in relation to a string key by using the native objet key property implementation available in js.
const put = (map, key, val)=> {
map[key]= val;
};
const get = (map, key)=>{
return map[key];
};
This implementation must be optimal, because it doses not have 'hidden' iterations on the data structure.
With 11 years in Front-End Dev, I'm skilled in JavaScript, React, Redux, and TypeScript. I'm passionate about learning and Sharing knowledge Let's grow together!
With 11 years in Front-End Dev, I'm skilled in JavaScript, React, Redux, and TypeScript. I'm passionate about learning and Sharing knowledge Let's grow together!
With 11 years in Front-End Dev, I'm skilled in JavaScript, React, Redux, and TypeScript. I'm passionate about learning and Sharing knowledge Let's grow together!
I think it's interesting to learn how data structures work under the hood, but for practical code, Javascript (and almost all programming languages) already have this natively implemented with objects and
Map, and you're not going to beat the performance and security of V8 with js code.True, totally true,
It is just like we are writing sorting algorithm for our own practice. as Javascript's sorting algorithm even better in compare to QuickSort.
So Here I am not challenging to V8, as they are written in c++, 😊.
Hope you understand.
I fail to see the reasoning of using HashMaps in js. You obtain the same behaviour of having stored a value in relation to a string key by using the native objet key property implementation available in js.
const put = (map, key, val)=> {
map[key]= val;
};
const get = (map, key)=>{
return map[key];
};
This implementation must be optimal, because it doses not have 'hidden' iterations on the data structure.
But then again, I didn't compare the performances
Correct, The only scenarios where we can use Hashmap which I know is Least recently Used cache Algorithm. There we can use.
That combines HashMap + Double Linked list to achieve all the Operations.
But for simple use cases we can use simple JSON objects.
I hope this helps.
Informative
Thank you Abhinav
True, we can do the same. Sorry I missed those earlier.
So, are these just like dictionaries in Python?
Dictionaries are a native implementation of hash maps, and Javascript objects are too, so yes
Oh, I see. Thank you!