How to Implement a Hash Table in JavaScript

Sdílet
Vložit
  • čas přidán 22. 12. 2019
  • Learn how a map/dictionary/hash table works underneath the hood by implementing your own version in JavaScript.
    Code: gist.github.com/benawad/7a71d... ​

    ----
    Follow me online: voidpet.com/benawad
    #benawad
  • Věda a technologie

Komentáře • 179

  • @Akshatgiri
    @Akshatgiri Před 4 lety +97

    I was asked to create a hash table ( in js ) from scratch in an interview and I bombed it. Thanks for the vid. 👍

    • @ben790924
      @ben790924 Před 3 lety +4

      It had to be Google、Facebook、Amazon interview i guess XD

    • @MrPaulsonantajo
      @MrPaulsonantajo Před 3 lety +13

      Some non-JS developer comes as a JS interviewer and ask all these questions about the hash map and hash table and create a big deal out of it. Basically, the JS object serves the purpose of the hash table and there is a high chance that most of the JS developers never heard about the hash map.

    • @vivekgoswami1474
      @vivekgoswami1474 Před 2 lety

      Really bro

  • @hnasr
    @hnasr Před 4 lety +51

    I like your videos Ben, unique content and always questioning how things are made.

  • @kzakaria91
    @kzakaria91 Před 4 lety +185

    i actually like this kind of videos more than frameworks, being self taught always feels like im missing on cs fundamentals even though i can set up graphql with the newest hip frontend framework LOL.
    keep em coming ben, appreciate the great work

  • @stephenyin3509
    @stephenyin3509 Před 4 lety +7

    Amazing video! I use dict/object/hashtable a lot in my daily programming, but never have a thought how it works. This video just gives me a great intro of the principle behind the hashtable under the hood! Keep working Ben! You should deserved to have millions of subscribers!

  • @lsamax4468
    @lsamax4468 Před 4 lety +44

    when you call a setItem again with same key, the output will like as [[["firstName", "bob"], ["firstName", "sam"]]],
    after that, you call the getItem will get "bob", cus you just return the first element in table.
    so, you need to adjust the setItem method as below (O(n)):
    if (this.table[idx]) {
    const item = this.table[idx].find(x => x[0] === key);
    if (item) {
    item[1] = value;
    } else {
    this.table[idx].push([key, value]);
    }
    } else {
    this.table[idx] = [[key, value]];
    }

    • @ErikBongers
      @ErikBongers Před 4 lety

      Jep. Been couple of weeks now, and not too many people who noticed this, it seems.

    • @bawad
      @bawad  Před 4 lety +9

      Good catch idk how I forgot about this

  • @nstwin9
    @nstwin9 Před 4 lety +14

    Yessss! More data structures and algorithm videos please 🙏🙏🙏🙏🙏🙏🙏🙏🙏

  • @sbrugby1
    @sbrugby1 Před 4 lety +8

    great tip on Quokka. It feels like a jupyter notebook or something for js in vscode. I'm loving it.

  • @purdysanchez
    @purdysanchez Před 4 lety +9

    Great job on a sample implementation of a hashtable in JS!

  • @OfferoC
    @OfferoC Před 4 lety +1

    Great video, thanks. I would love a video comparing different hash functions.

  • @Jason_Lucero
    @Jason_Lucero Před 3 lety +4

    Damn ben, never really watched you for your tutorials but damn, this was clean

  • @theemacsen1518
    @theemacsen1518 Před 4 lety +1

    Great video as always Ben!!

  • @mohamedaljamil6334
    @mohamedaljamil6334 Před 4 lety +2

    I finally understood hash tables. thank you

  • @lukehatcher98
    @lukehatcher98 Před 3 lety +1

    Great video. I implemented a bottom threshold where if the table is less than .25% full, create a new table of half the length and rehash

  • @IlhanNegis
    @IlhanNegis Před 4 lety +6

    very nice one, funfact, in js actually object is base, array is derived from object, so actually arrays are hashmap with number keys.

    • @bawad
      @bawad  Před 4 lety

      oh really, that's interesting, so how does the object work underneath?

    • @IlhanNegis
      @IlhanNegis Před 4 lety

      that I'm not sure, but all bit at the metal. but on language itself the base is object, do not quote me but firefox engine has a native array implementation for performance afaik.

    • @mzcustom2
      @mzcustom2 Před 4 lety +2

      Entering typeof([ ]) in the console of all my browsers confirms your claim. Have been using the object as hashtable in Javascript since day one and never felt the necessity of the implementing one. I believe the dense array is the way to go when possible cuz it's just a wrapper for a C array.

    • @alexnezhynsky9707
      @alexnezhynsky9707 Před 4 lety

      Pretty sure object derives from an array, and all arrays are actually fixed in size, so the object just computes indexes with a hash function

    • @nekran
      @nekran Před 4 lety

      In others langages(like java): object use hash table internally but with the V8 engine it use another technique. And for optimization purpose object are transformed in array (pre "turbofan" at least, not sure with the new "turbofan" compiler)

  • @jasonjones5079
    @jasonjones5079 Před 4 lety +2

    Really enjoyed this!

  • @MachiriReviews
    @MachiriReviews Před rokem

    This is a really good guide. From this I was also able to write a function that reassigns values.

  • @Sinan997
    @Sinan997 Před rokem

    dude this is golden, appreciated that

  • @juanmarino1186
    @juanmarino1186 Před rokem

    watching you code is fun

  • @fezekileplaatyi7224
    @fezekileplaatyi7224 Před 3 lety +7

    Hey Ben, do you have other tutorials for other Data Structures? Man you explained this very nicely and easily

  • @YaohanChen
    @YaohanChen Před 4 lety +5

    One way to simplify resize() is to just save the current table in a variable, assign this.table to the resized one, and then call setItem() for all the pairs in the old table.

    • @OfferoC
      @OfferoC Před 4 lety +1

      need to be careful about recursion in that case

  • @joestrkr
    @joestrkr Před 4 lety +1

    Very cool stuff. Love your channel :)

  • @hugothms
    @hugothms Před 3 lety

    That's very clear ! Thanks buddy

  • @tajpouria
    @tajpouria Před 4 lety +30

    I suggest you to make a series about functional programming pattern in TS/JS. That's one of the most popular concepts that's not any proper content on CZcams about it, best regards...

  • @lucasdelbel7376
    @lucasdelbel7376 Před 3 lety

    Awesome video.Thank you so much.

  • @godnessy
    @godnessy Před 2 lety

    Very cool video, thanks!

  • @MrREALball
    @MrREALball Před 4 lety +12

    2001 isnt prime, cuz 2+0+0+1 % 3 = 0, so u could divide it by 3

  • @producdevity
    @producdevity Před 4 lety +2

    I love the explanation. It would be great if you could give an example where this would be useful , because I can’t come up with one by myself

    • @purdysanchez
      @purdysanchez Před 4 lety +2

      It's useful as a teaching example of a basic hashtable implementation

    • @spaghettiking653
      @spaghettiking653 Před 3 lety +2

      What he said, because Objects in JS already do this by default and are faster than the manual implementation. This is just an example of how it works underneath the hood, which is very fascinating. Btw, this is probably way more useful in lower-level languages, especailly those without an existing hashmap object.

  • @frankie_goestohollywood

    Thank you, Ben!!! :-)

  • @rayan361ify
    @rayan361ify Před 4 lety

    Yes !!! DS thanks Ben .👍

  • @evanstapp
    @evanstapp Před 4 lety +1

    Good one Ben

  • @iamjohnhenry
    @iamjohnhenry Před 4 lety +7

    You mention that a hash table (object) is implemented as an array, but it was originally the other way around -- the first implementation of javascript lacked "real" arrays and implemented them by adding a "length" method to an object that used number converted to strings as keys. Not sure about the underlying implementation though...
    Also, I don't think this is technically a hash function as the hashStringToInt function's run time is dependent upon string length and not constant.
    I want to add, however, that I recently discovered your channel and I really like the stuff you're doing here! Keep up the good work!

    • @31redorange08
      @31redorange08 Před 3 lety

      Why does the hash function have to be constant? How to achieve this?

    • @marcossidoruk8033
      @marcossidoruk8033 Před rokem

      @@31redorange08 it doesn't.

    • @marcossidoruk8033
      @marcossidoruk8033 Před rokem

      Hash tables are not constant time with respect to key length only with respect to number of elements.

    • @31redorange08
      @31redorange08 Před rokem

      @@marcossidoruk8033 I know. I just wanted to bust their "knowledge" in a nonconfrontational way. 🙂

  • @paco3447
    @paco3447 Před 4 lety +5

    Good. But keep in mind that Hash tables despite perform fast with insertion, deletion and fetching, are really bad for searching wise operations, in the later case is better to use binary search tree structures.
    Other issue that comes to mind is that choosing odd primes for multiplier, in order to reduce collisions, are better suited for English words as is empirically taken with that language in mind.

  • @brNoMundo123
    @brNoMundo123 Před 2 lety

    Great video!

  • @ditoorkodashvili6018
    @ditoorkodashvili6018 Před 3 lety +2

    Correct me if I am wrong but the way the setItem is implemented you may get a duplicate keys, because you are not replacing a pair if the key already exists in the array.

  • @28bits20
    @28bits20 Před 4 lety +7

    Nice tutorial. One note though: at 12:24 you should’ve checked if(this.table[idx] === undefined) instead because if someone has set the value to 0 or an empty string it will not evaluate to true.

    • @bawad
      @bawad  Před 4 lety +1

      good catch

    • @31redorange08
      @31redorange08 Před 3 lety +1

      Bad catch. There will either be an array or undefined, never 0 or an empty string.

    • @28bits20
      @28bits20 Před 3 lety

      redorange Check again. He is checking if the value is set for a given key. The value could be anything including 0 or an empty string not just an array or undefined.

    • @doodoostickstain
      @doodoostickstain Před 2 lety

      What's wrong with having a 0 or empty string? Maybe I'm mistaken for reasons, but if I stored a 0 or '', i'd prefer for someone to NOT overwrite it because they feel it shouldn't exist. can anyone explain? they're legal values, after all, though they may not make much sense without context. we should PROTECT our values :D not destroy them

    • @doodoostickstain
      @doodoostickstain Před 2 lety +4

      ok never mind I get it now, took a moment :D

  • @riexrickgaming
    @riexrickgaming Před 3 lety

    do we need to create this hashtable implementation on our own or there is efficient library/ implementatiom existed already? just want to know the best practices

  • @jmoo4457
    @jmoo4457 Před 4 lety +4

    Small improvement suggestion. The `setItem` function should probably take into account of update on same key (i.e. when an item with the same key already exists). After that, `this.numItems++` should only happen when a new key is inserted. Otherwise we can do `setItem("sameKey",123)` multiple times and keep increasing the hash table when it doesn't need to be bigger.

    • @jmoo4457
      @jmoo4457 Před 4 lety

      Another improvement is to use a linked list instead of a generic array for the "bucket" in each indices. This will become useful when there is a need to delete items from the hashmap (which wasn't part of this implementation), since linked-list deletion is O(1).

    • @jmoo4457
      @jmoo4457 Před 4 lety +1

      I want to point out that this was an excellent intro to hash tables by Ben Awad, and he implemented one of the solutions for hash collision (Separate Chaining), but there are other strategies that can be used. I found GeeksForGeeks Hashing Set 1~3 videos helpful for learning about different strategies if you are curious. You can find them on CZcams.

  • @anantsharma9806
    @anantsharma9806 Před 3 lety

    In this implementation, we used an array to generate a hash value, so our performance is directly proportional to the length of key name we chose?

  • @salahalhashmi6528
    @salahalhashmi6528 Před 3 lety

    thanks for this course

  • @khadijasheikh8144
    @khadijasheikh8144 Před 2 lety

    Thank you so much this video is benefitfull i appreciate it .

  • @JaspreetSingh-eq2yk
    @JaspreetSingh-eq2yk Před 4 lety +6

    Inside the loop in your hashStringtoInt function should it be hash += (13*hash*s.charCodeat(i))%tableSize ?? Your solution has hash = (....) instead of hash+= (.....)

    • @kjl3080
      @kjl3080 Před 3 lety +2

      Yes, his bad, because rn it only hashes the last character

  • @superchillh3o
    @superchillh3o Před 4 lety

    thanks for sharing!

  • @nicolasguillenc
    @nicolasguillenc Před 3 lety +1

    Thanks man. 🙏🏽

  • @claydaman22
    @claydaman22 Před 4 lety +2

    This is cool and all but how would you use this in a real word app? Would I persist this to a DB?

  • @denistsoi
    @denistsoi Před 4 lety

    You can use //? to show the output at the end of the line number instead of console.log

    • @bawad
      @bawad  Před 4 lety

      I think that's only in the premium version

  • @Jun-zq3bn
    @Jun-zq3bn Před 3 lety

    what extension or shortcut did you use to auto input ;

  • @inasuma8180
    @inasuma8180 Před 3 lety

    Is there a more optimized way to resize the hash table? 🤔

  • @ajaykrishnareddy
    @ajaykrishnareddy Před 4 lety

    Hi , I currently using react hooks is there any way that use call back after setting the state using useState hook

    • @bawad
      @bawad  Před 4 lety

      what do you mean?

  • @adhupraba
    @adhupraba Před 3 lety

    great video... also what is your vs code's font name? I'd like to set for mine too...

  • @yaboiickydick9456
    @yaboiickydick9456 Před rokem

    At 19:50, why did you change to foreach instead of using a for loop? Was it for readability, or is there a deeper reason for this choice?

  • @JeremiahPeoples
    @JeremiahPeoples Před 2 lety

    This is good.

  • @pullrequest1481
    @pullrequest1481 Před rokem

    This is crazy!!! ❤❤❤❤

  • @ltserge3226
    @ltserge3226 Před 2 lety

    at 20:40 what command did you do to copy the line like that?

  • @samial-jabar9861
    @samial-jabar9861 Před 3 lety

    Very nice video

  • @arturluisoliveira
    @arturluisoliveira Před 3 lety +1

    sometimes I got the impression that ben is always laughing on the inside. hahaha.

  • @TadesseDev
    @TadesseDev Před 2 lety

    I am dancing now 😎, because I know the error that happens as you type it. 21:00, Great content buddy. Subscribed.

  • @petarthecodehunter3333

    Thank you!

  • @hanifabeg1699
    @hanifabeg1699 Před 3 lety

    which extension is he using for this auto onscreen console

  • @nilokillian
    @nilokillian Před 4 lety

    there is a bug in hashStringToInt func's logic : in For loop you're re-assigning Hash variable every circle. Someone suggested in the comment section to use += which is right but we also need to move the modulus out of the loop, otherwise we go outside of the array's length so

  • @md.akib5124
    @md.akib5124 Před 4 lety +1

    My DS class got so easy

  • @Kenbomp
    @Kenbomp Před rokem

    . Js can get quite complicated. But it work

  • @walo3000
    @walo3000 Před 4 lety +2

    you can also do ```person['lastName'] //?``` and get the same result as the console.log

    • @ugurcoskun5195
      @ugurcoskun5195 Před 4 lety

      premium?

    • @walo3000
      @walo3000 Před 4 lety +1

      @@ugurcoskun5195 I didnt realize before, but yes, its available in pro version. I will recommend Pro version, it has useful features.

  • @FunctionGermany
    @FunctionGermany Před 3 lety +1

    But why would you want to do this when we have Map?

  • @CardinalHijack
    @CardinalHijack Před 4 lety

    Do you or does anyone know if places like Google will ask you to do this in an interview?

  • @SinanAkkoyun
    @SinanAkkoyun Před 3 lety

    How high is ur monitor?

  • @Tonestire
    @Tonestire Před 3 lety

    can you go through the other extensions you have installed in vs code? what's the one that shows you the green boxes on the left?

    • @kjl3080
      @kjl3080 Před 3 lety

      That’s just a visual extension for uncommitted/unsaved changes

    • @Tonestire
      @Tonestire Před 3 lety

      @@kjl3080 what's it called?

    • @kjl3080
      @kjl3080 Před 3 lety

      @@Tonestire idk what that specific theme is called, but you should be able to find it in the extensions marketplace iirc

  • @albertwoo6246
    @albertwoo6246 Před 4 lety

    I have a dumb question. In some other languages like c#, if the array`s length is 10, but your hash function calculated the index to be 13 then how can you set value to that index because the index can only be from 0 to 9? Looks like in javascript the array is a dictionary right?

    • @bawad
      @bawad  Před 4 lety +1

      that's why we mod by the length of the array so we never get a number bigger

    • @albertwoo6246
      @albertwoo6246 Před 4 lety

      @@bawad Thanks! I did not noticed that.

  • @tahaAFK
    @tahaAFK Před rokem

    3:55 well you can use string as an index there in JavaScript.

  • @vorname1485
    @vorname1485 Před 4 lety +2

    Do you know this? The way you assign the (arrow)-methods is equivalent to assigning via *this.getItem = expression* , which means its bound to the HashTable instance and not prototype. Means, each HashTable method will create new method instances, instead of those methods being instantiated once on prototype. That is the difference between the syntax-sugared *getItem(key) {}* and *getItem = (key) => {}* (ignoring the this context on arrow function). The former is on prototype, the later on instance. Does not make much difference here though, but good to know if you have a lot of instantiations of those types.

    • @maheshsundaram8012
      @maheshsundaram8012 Před 4 lety

      Thank you for explaining that

    • @mihaimanole2643
      @mihaimanole2643 Před 4 lety

      That means that in the second form (arrow) I can access the instance properties directly, like table instead of this.table, isn’t it?

    • @vorname1485
      @vorname1485 Před 4 lety +1

      @@mihaimanole2643 no, you can not because table is not a local variable. also when desugared. So you will still need this.

  • @sbin9161
    @sbin9161 Před 2 lety

    Thanks :)

  • @filippasek6
    @filippasek6 Před 4 lety +1

    Your hash function only takes the last char

  • @christalley5192
    @christalley5192 Před 4 lety +1

    This was super helpful. Small question about the time complexity. Since the resizing only occurs at a certain point, will the time complexity still remain O(n) at the worst? Great video though thank you.

  • @dannyjiujitsu
    @dannyjiujitsu Před rokem

    This video was all over the place.

  • @ebosetalee7159
    @ebosetalee7159 Před 3 lety

    Although this was uploaded in 2019, I noticed something while using new Array(this.size), If the size of our array is 100 and add an item to 200 your array automatically increases to 201. Therefore, no need to resize the array.

    • @alext5497
      @alext5497 Před 2 lety

      If the new item has a collision, the size will not increase. Also, depending on which part of the video your referring to, he is not always just pushing items to the end, so again, your not increasing the size.
      The way I would prefer to do it is to make a internal method getsize () and call it only if needed to avoid unnecessary computation.

  • @svmathtutor
    @svmathtutor Před 3 lety

    1:27 , 2:55 Ctrl + Shift + P on Windows machine to get the menu to Start Quokka on Current File.

  • @sqwale7
    @sqwale7 Před 2 lety

    Seems to be a bug?
    Your hush function will only be based on the last character of your string. Not a function of the entire string!
    What you may want to do is create a running sum of your salt + charCodeAt(i)

  • @aleksd286
    @aleksd286 Před 4 lety

    Do you think someone will ever need to create their own hash table in JS like that? Because github/npm etc are full of somebody else's made hash tables

    • @candfsolutions
      @candfsolutions Před 4 lety +2

      In the beginning, re-using existing modules is fine, but eventually it's good to understand what's happening under the hood. Building your own is the often best way to get there.
      For example, after lightly using MVC frameworks I decided I needed to understand them better, so I built my own. It's nothing special and certainly nothing I'll put into production, but when I was done I had a full, solid grasp of the concepts and mechanics of MVC, as well as some of the tradeoffs/pitfalls involved in using the pattern.

    • @aleksd286
      @aleksd286 Před 4 lety

      @@candfsolutions indeed for self learning I guess this is ideal, probably these type of stuff you don't want to use in production just, unless you want to be responsible for maintaining it, bug fixing, and adding features

    • @bawad
      @bawad  Před 4 lety +1

      99.9999% of the time you won't need to implement your own hash table.
      I've always used the one already implemented for me

  • @chungleee
    @chungleee Před 4 lety

    is there a difference between obj.foo and obj['foo'] ?

    • @FauzulChowdhury
      @FauzulChowdhury Před 4 lety +2

      No in terms of expected result. Yes if you are e.g, Trying to make a object key from the value of foo. obj.foo won't work but obj['foo'] will work.

    • @ericlarson7740
      @ericlarson7740 Před 4 lety +1

      The 2nd option allows for more property names possibilities with characters that wouldn't be allowed with the 1st option. Take for instance:
      var obj = {'//bar': 'This property name is only possible with quotations'};
      obj.//bar is not valid while obj['//bar'] is allowed.

    • @FauzulChowdhury
      @FauzulChowdhury Před 4 lety

      @@ericlarson7740 ya... Thanks for a better clarification. :)

    • @vorname1485
      @vorname1485 Před 4 lety

      Under the hood its the same operation. But syntactically the former does not allow you to use space or other tokens, because it would be indistinguishable, so you have the later syntax, which is distinguishable.

  • @redlobsta1
    @redlobsta1 Před 2 lety

    @10:16 for lines 4 to 6, why would you want to use a for loop that runs i many times, to finally generate a single number (hash) at the end,
    seems a bit unnecessary as lets say our string is "firstName" - all that matters is charCodeAt('e') (the last letter) and that determines our hash, all the other letters "firstNam" when run through the for loop, get overwritten by the last iteration.

  • @rorisjack1218
    @rorisjack1218 Před 4 lety

    Hey man, great video!
    Just a question, what font are you using on VSCode? On Windows my fonts look really pixelated and ugly. Thanks!

    • @bawad
      @bawad  Před 4 lety

      I think I'm using the default one

    • @kjl3080
      @kjl3080 Před 3 lety

      Try ClearType or increasing your font size

  • @antonomelchuk4795
    @antonomelchuk4795 Před 3 lety

    How do you show console.log in real time?

    • @kjl3080
      @kjl3080 Před 3 lety

      Quippa I think

    • @kjl3080
      @kjl3080 Před 3 lety

      *quokka it’s not free

  • @peterm.souzajr.2112
    @peterm.souzajr.2112 Před 4 lety

    thanks

  • @NurthinAziz
    @NurthinAziz Před 4 lety

    Subscribed

  • @vorname1485
    @vorname1485 Před 4 lety

    Noticed, there is probably a bug (did not test it, just from watching the video) with empty string passed as key, the length will be zero and so the returned int key will be 17, which is out of bounds of the initial table of length 3 :)

    • @bawad
      @bawad  Před 4 lety

      nice find!

    • @vorname1485
      @vorname1485 Před 4 lety

      @@bawad I like your interesst in understanding how things work. I also like to do stuff like that myself for fun and it helps understand things better and being more creative in finding solutions for problems. Especially, like in this case, when its actually part of language, but do it more *low level* (if that is the correct term here..) yourself. For example some ui & interaction rendered on canvas, including event handling - you can obviously not add event listeners to drawn objects natively on a canvas. Layouting system to arrange ui elements, etc.

  • @binrui
    @binrui Před 4 lety

    Delicious :)

  • @hakanaki
    @hakanaki Před 2 lety

    Can someone pls explain the difference between a hash map and a hash table ?

    • @obetreyes9187
      @obetreyes9187 Před 2 lety +1

      Here's the way I understand it:
      Hash Table: what we call the concept in Computer Science
      Hash Map: what it is called in Java
      Hash Set (HashSet): the case where we only care about the unique keys (or you can see it as a Hash Table where we ignore the values, we just want to know what is the set of unique keys)
      Or simply,
      Hash Table (CS) = HashMap (Java) = Dictionary (Python)
      Hash Set (CS) = HashSet (Java) = Set (Python)

    • @hakanaki
      @hakanaki Před 2 lety

      @@obetreyes9187 thank you very much

  • @luishenriqueandradepellizz680

    I laugh so LOUD after he says to himself at 22:13 * Oh yeah I`m just a NOOB *, but I was crying inside because I have no idea what was happening and needed to pause while(myUnderstanding < 1)

  • @RavnitSuri
    @RavnitSuri Před 3 lety

    I don't understand... why are we making these with Arrays again and not objects?

    • @vitorgouveia5378
      @vitorgouveia5378 Před 3 lety

      Me too, like, why not just use objects as shown in the beginning of the vídeo? Why do all that extra work?

  • @ekvedaras
    @ekvedaras Před 3 lety

    Not that anybody asked, but I always watch your videos at 2x speed. Cool stuff though :) I would have liked a few sentences about why and when to use something like this or is it just a fun little exercise.

  • @amanlearnscode
    @amanlearnscode Před 4 lety +1

    the load factor of HashMap in Java is 0.75 :)

    • @rickross9829
      @rickross9829 Před 4 lety

      Java or JS?

    • @mihaimanole2643
      @mihaimanole2643 Před 4 lety

      rick ross It’s very handy to peek the implementation of HashMap from Java then the one from V8 or other JavaScript engine. Which, of course, will be not implemented in JavaScript, but most likely in C++.

  • @ExtremelyTastyBread
    @ExtremelyTastyBread Před 2 lety

    Google better not ask me to code one of these entirely from scratch in my phone screen tomorrow, because I guarantee I can't do it

  • @MrEnsiferum77
    @MrEnsiferum77 Před 4 lety +2

    The problem with this data structure courses is that no one like to take deep dive in more hard structures like trees(but no binary or n-ary trees) etc.. and more complicated alghortims that are used in AI and are tightly connected with trees and similar structures.

  • @julianavar3836
    @julianavar3836 Před 4 lety

    or you could use a map

  • @0xatul
    @0xatul Před rokem

    I miss the old Ben

  • @hamzadata
    @hamzadata Před 2 lety

    We now know why you had to wear glasses

  • @bloodandbonezzz
    @bloodandbonezzz Před 4 lety +4

    Why use a hash when you can use an object?

    • @jeromesnail
      @jeromesnail Před 4 lety +1

      I guess it's just to show how it works under the hood.

    • @sahilGupta217
      @sahilGupta217 Před 4 lety

      @@jeromesnail but actually which one is used more often??

  • @colloidalsilver177
    @colloidalsilver177 Před 2 lety

    What do you mean by “spreading out the keys” ?you’ll have to excuse me im a dummy

  • @azumatomlinson3474
    @azumatomlinson3474 Před 2 lety

    My bookmarks:
    5:48

  • @elbozo5723
    @elbozo5723 Před rokem

    or… and mark my words…
    let table;
    table[“key”] = value;

  • @MrBazookatoon
    @MrBazookatoon Před 4 lety

    Why would you need a hashtable in Javascript when you have JSON?

    • @bawad
      @bawad  Před 4 lety +2

      I wouldn't actually use this, it's more for learning purposes