My first impression is the same as yours
But after I realised the implementation, everything will be correct
if you use table[key], there is no way to detect if an element already exists in the object, especially you are using UUID for the key part
but the solution is to use the hash of that object as the UUID and the key, so you can have everything unique(the same element will give same hash), but still can add "infinite amount" of element without implementing your key generator
Yeah, the post is just using JS to show you how you might implement hash tables to explain how they work under the wraps. You're obviously going to use the built-in unless you have a really good reason not to
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Aren't JavaScript objects already hash tables or how does the browser/node implement objects?
Several dynamic languages, such as Perl, Python, JavaScript, Lua, and Ruby, use hash tables to implement objects.
So why not directly use table[key] = value?
My first impression is the same as yours
But after I realised the implementation, everything will be correct
if you use table[key], there is no way to detect if an element already exists in the object, especially you are using UUID for the key part
but the solution is to use the hash of that object as the UUID and the key, so you can have everything unique(the same element will give same hash), but still can add "infinite amount" of element without implementing your key generator
the code example is just an example
Yeah, the post is just using JS to show you how you might implement hash tables to explain how they work under the wraps. You're obviously going to use the built-in unless you have a really good reason not to