Hash Tables – Beau teaches JavaScript




Hash tables are a quick way to implement associative arrays, or mappings of key-value pairs. Find our more and learn how to create one in JavaScript.

💻 Code: http://codepen.io/beaucarnes/pen/VbYGMb?editors=0012

🔗 Info: http://www.willvillanueva.com/javascript-hash-tables/

🐦 Beau Carnes on Twitter: https://twitter.com/carnesbeau

⭐JavaScript Playlists⭐
▶JavaScript Basics: https://www.youtube.com/playlist?list=PLWKjhJtqVAbk2qRZtWSzCIN38JC_NdhW5
▶Data Structures and Algorithms: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkso-IbgiiP48n-O-JQA9PJ
▶Design Patterns: https://www.youtube.com/playlist?list=PLWKjhJtqVAbnZtkAI3BqcYxKnfWn_C704
▶ES6: https://www.youtube.com/playlist?list=PLWKjhJtqVAbljtmmeS0c-CEl2LdE-eR_F
▶Clean Code: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkK24EaPurzMq0-kw5U9pJh


We’re busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

Join our community at https://freecodecamp.com
Read great tech articles at https://medium.freecodecamp.com

Original source


13 responses to “Hash Tables – Beau teaches JavaScript”

  1. I think I might be missing something here, wasn't the point of a hastable to have O(1) reads, inserts, and deletes? This is running O(n) blocks for each of those operations. Is there a way to get those down to O(1) in Javascript?

  2. I've seen like 5 videos trying to explain hash tables, and this is the only one that made it clear, and it was the only that used code. I guess I understand things better from how they work than from prattle and pictures.

  3. Really weird mixture of var let and const here. Your storage can be a const since the array location in the memory doesn't change, only the array items do. all the functions should also be consts as well. there's really no point in using var anymore. great video otherwise!

  4. Can you explain what do you mean by "When (inserted=== false), then push the key,vales into storage array. But how do we get multiple entries for the same bucket? It means collision right? But how can it happen when you don't find the same key which actually happens in previous case i.e. when the key exists already. Help me.

  5. Nice explanation. Good work, Beau Carnes !
    Line 42,
    There is a use case in Remove method, that is the key doesn't exist in array.
    The code logic works. If we may test it separately, it'll be more clear.

Leave a Reply