DEV Community

Discussion on: Completed JavaScript Data Structure Course, and Here is What I Learned About Hash Table.

Collapse
 
okbrown profile image
Orlando Brown

I've always found that kind of implementation overkill. Until required.

Would hurt to create an obj={} assign values obj.key=val and return obj[key]?

Or obj = new Map(); set/get et al?

Collapse
 
maikomiyazaki profile image
Maiko Miyazaki

Thanks for your comment!

Yes, we can assign key-value pairs obj.key=val, and we get value back when return obj[key]. Using Map is also sensible too. ;)

We just need to be aware that when assigning keys with dot notation, and if we are passing the key through variable, the variable name will be actually assigned as the key(variable won't be recognized).

I'm going to update the article to include this thought! Thank you for your ideas! :)