JavaScript Maps & WeakMaps

preview_player
Показать описание
ES6 Introduced new Data Structures Map and WeakMap in JavaScript. Understand difference between JavaScript objects and Maps.

Article and code samples from this tutorial

Please be my patreons on patreaon

Follow me for technology updates

Help me translate this video.
Рекомендации по теме
Комментарии
Автор

Good tutorial. What would be great is if you explained not only what Maps and WeakMaps are, but when and why you would use them over a traditional object.

Cazineer
Автор

0:50 every time i watch your video when you say *"techsith tutorials"*
it feels me like that you are saying *"Taxi Tutorials"* and then i smile :)

alinawaz
Автор

TO say thank you will not do justice with your teaching. I have never learnt coding easily before watching your videos. You are a great mentor. Keep it up.

yousufkhan
Автор

Man you just explain things really simply.. loved you're videos ❤

hamzaiqbal
Автор

Hi bro, last 3 days I watching ur interview solve question in js and ur all video. It's really helpful, yesterday I attend the interview in CTS, it very helpful for me, keep going bro...

jaganramanikanth
Автор

2:44 JavaScript Object not support any Object as key. It parse an Object toString(), and treat '[object Object]' as key

duxingsky
Автор

You are a Genius, there is so many materials out there but just make it easy...Thank you

luthermaria
Автор

you explain in very simple way which make easy to understand.Thanks a lot

laxmiprajapati
Автор

It helps me a lot to learn js concept thanks for this amazing videos.

monalithakre
Автор

Very nice and simple example at the end about the difference between a map and a weakmap. This helped me tremendously to understand. Thank you

FidelGuajardo
Автор

its nice that we can make object a key but my question is why would anyone ever wanna do that ?

debasishpothal
Автор

Answer to you question: x was not garbage collected, it will stays there until console refreshed or you forcefully delete it from map

landgemukesh
Автор

Another great video as always! Thank you for taking the time to make this and share it with all of us! Near the end of the video, you had a small homework assignment, I want to take a guess as to why the value remained... I suspect when it was initially created using var the value got attached to the global space, additionally I think when creating the map or the weak map using const or let will keep the value contained inside the function scope. Please let us know if you post an answer to the question you raised. As always thumbs up and I am subscribed with notifications turned on, I don't want to miss any videos from your channel!

ErnestGWilsonII
Автор

for of is available with regular object as well, but we will have ti iterate through Object.entries(obj)

ganeshshetty
Автор

The one thing that I like about you is the detail of your tutorials. I cannot figure out how you learn these things with such details. Can you tell what resources you use to learn these things. Thanks for the video SIR

creativeuk
Автор

This might look like it's the same as setting props on an Object but what ends up happening is you get a hash conflict. toString is used to create the key which will result in two entries with the same key ( [object Object] ). Then when you retrieve it has to iterate over all entries with this key and find the proper entry by strict equality.
What this is means is that in a way of saying map.get(obj) is now an O(n) operation compared to O(1) in the case of accessing an object unless V8 internally sets the address of the object as key which would make sense.
Also the reason you don't get a key in there is because the object gets garbage collected so the reference is gone. If you declare the object with var, global will keep a reference to it.

totaltotal
Автор

Can you please give a real world scenario where Maps are useful?

Godwin
Автор

Its still in memory, because JS engine not taken the key in garbage collection array. Restart the browser create a new cycle of garbage collection. Please correct me if I'm wrong :)

AC-lqpz
Автор

thanks, please make a video related to how dispatch works in react-redux

chandanpradhan
Автор

WeakMaps will not retain entry because it only saves the reference where as Map actually saves a copy of the key object and so it retains even after GC. Please correct if am wrong.

narayanam