Hi, adding all those empty objects to the map (at ~12:34) was a bit misleading. From my tests, I'm pretty sure that you would never have been able to run myMap.delete({}) or myMap.has({}) because each of those empty objects is stored at a different location in memory. So what's the point in creating them? You appeared to be showing that one of the advantages of Map compared to a regular object is that you can create duplicate keys in a map (i.e. multiple empty objects). But in fact ''duplicate" keys are NOT possible in myMap. In your example, each empty object you create as a key is a different thing in memory. And because you have created those keys without a reference to them in memory, i.e. being stored as a variable, once those keys are created, you can no longer access them using .has({}). Let me know if I'm wrong.
Agreed. it would've been a much more realistic example if he had used two visibly different objects to prove his point. if you tried to do that with a regular object, you would end up with the key just being "[object Object]" for any arbitrary object, no matter it's properties. Still, everything he said was technically not wrong, but probably could've been made more clear by using a better example.
There is a recurring meme in developers community about writing obfuscated code so that no one else can understand it and you become irreplaceable. I feel like people responsible for JS standards took that as a guideline and are introducing features that have possibility to make JS even harder and convoluted. And by this logic demand for JS developers will rise indefinitely. I really do not see a point in Sets and Maps. Why not introduce just a `unique` method on existing arrays? It will do the same thing as [... new Set()] without clutter that Set introduces. And I also do not see how benefits of Map outweighs possibility of writing convoluted code. Who do F needs objects as keys. This screams to me an overengineered solution.
Nice video, please make one more for advance use of SET and MAP, covering more scenarios, where it should be used practically instead of any other data structure.
For your information, you can not store multiple same keys of type number or string in MAP. Multiple same keys can only work with non-primitive datatype , when set as a key
Jaha pana Tusi Great ho :). A beginner like me in Javascripts. I was able to understand your map & set concepts and am able to implement the same in my code. working successfully. Thanks & God bless you
so maps can hold any value as either the key or value from what ive read. which means the key itself can be any primitive value or object. im having trouble understanding what the use case would be for using an object as a key? i just cant seem to wrap my brain around it was wondering if you had any insight?
@@quanlili1157 Are you sure, you've watched the video. The answer should be, "it would delete both keys". So, watch it and you will say at the end, WTF
nice vide, finally i got it the difference and why it is useful. may i ask you what is that extension with the rocket down below that it says 2.3h? is like a focus mode activated?
how to delete object inside of [1, 2, 3, 4, 6, {id: 7}] i wanna achieve to delete object {id: 7 } with Set delete method, i would be like this mySet.delete({id: 7}) is it right ?
There is an extension called 'Code Runner'. Install it and you will see a 'play' icon to the extreme right . Just open terminal and results would be seen there .
Thank you for your explanation and examples they are very useful, I also read the doc but your explanation makes things a lot easier~ Great thanks, one sub for ya~
I guess I don't get the value of a _set_ object. Surely it has to have more than just being unique. It'd be easy enough to write a method to remove redundant entries from an array. Where are the methods for doing set intersection, union, and subtraction, for instance? In _set theory,_ you use these operations all the time.
2:06 It's amazing as a beginner trying to learn javascript, how often a decent video gets ruined because the teacher uses a term that is totally new without explaining it. So many people that know how to do something don't actually know how to tech things to beginners because they use terms that are more advanced.
Set
3:10 add method
4:33 delete method
5:07 clear method
5:33 has method
6:00 size property
Map
12:05 set method
12:57 delete method
13:45 clear method
14:04 has method
14:40 size property
Man I Thank You Strongly For Make Everything Crystal Clear..
Your coding flow is nice. The smooth use of shortcuts and line movements are fantastic.
Glad you think so!
7:50 - map
Hi, adding all those empty objects to the map (at ~12:34) was a bit misleading. From my tests, I'm pretty sure that you would never have been able to run myMap.delete({}) or myMap.has({}) because each of those empty objects is stored at a different location in memory. So what's the point in creating them? You appeared to be showing that one of the advantages of Map compared to a regular object is that you can create duplicate keys in a map (i.e. multiple empty objects). But in fact ''duplicate" keys are NOT possible in myMap. In your example, each empty object you create as a key is a different thing in memory. And because you have created those keys without a reference to them in memory, i.e. being stored as a variable, once those keys are created, you can no longer access them using .has({}). Let me know if I'm wrong.
Agreed. it would've been a much more realistic example if he had used two visibly different objects to prove his point.
if you tried to do that with a regular object, you would end up with the key just being "[object Object]" for any arbitrary object, no matter it's properties.
Still, everything he said was technically not wrong, but probably could've been made more clear by using a better example.
There is a recurring meme in developers community about writing obfuscated code so that no one else can understand it and you become irreplaceable.
I feel like people responsible for JS standards took that as a guideline and are introducing features that have possibility to make JS even harder and convoluted. And by this logic demand for JS developers will rise indefinitely.
I really do not see a point in Sets and Maps. Why not introduce just a `unique` method on existing arrays? It will do the same thing as [... new Set()] without clutter that Set introduces.
And I also do not see how benefits of Map outweighs possibility of writing convoluted code. Who do F needs objects as keys. This screams to me an overengineered solution.
@@anj000 I have used objects as keys before. it is useful to work with data from a relational database
@@anj000 What's the point of making JS harder and convulated? Makes no sense. btw it's no private matter fater all...
Nice video, please make one more for advance use of SET and MAP, covering more scenarios, where it should be used practically instead of any other data structure.
Thanks for the explanation! And from my understanding 'Set' is the best way to always ensure correct key order which a regular object can't rely on.
the way youre explaining is so different. such clarity
Wow, no more search abt JS Set n Map, thank U so much Bro!👍
For your information, you can not store multiple same keys of type number or string in MAP. Multiple same keys can only work with non-primitive datatype , when set as a key
So helpful and easy to understand with your explanations and example cases. Thank you!
Jaha pana Tusi Great ho :). A beginner like me in Javascripts. I was able to understand your map & set concepts and am able to implement the same in my code. working successfully. Thanks & God bless you
Also, you can use get() to get the value from a Map property by its key.
Probably the most important one lol
yea i was skipping back and forth looking for where he referenced the map value lol
lol I needed this video 5 hours ago before my technical assessment.
Really nice explanation, thanks you. I expected to also learn Map.get.
thaks for this awesome tutorial, very helpful, cleared my confusion about sets and maps. thnks
Well explained, thank you.
Thanks!
Clear and concise! But you forgot to mention the get methods to get the value after setting
A video with more practical examples would be great! Nice video!
nicely problem solution approach! keep it up
This is a great introduction!!
Awesome bro. Please keep it up.
so maps can hold any value as either the key or value from what ive read.
which means the key itself can be any primitive value or object. im having trouble understanding what the use case would be for using an object as a key? i just cant seem to wrap my brain around it was wondering if you had any insight?
Please make a more videos on Javascript. Which will help to solve Data structures and algorithms problems
Thanks for the video. But, in the Map, why would you want to have an empty object as the key? How would you access that item in the Map
You miss very important aspect, how to loop over them.
looping over an object isn't specific to Maps/Sets
Deconstruct into an array and loop over said array
[...myMap].forEach(value => {...})
forEach
Thank you. Really appreciate this vid. Subbed!
thanks, keep uploading!
Thank you soo much! As I'm just starting out, it really means a lot!
Great video, thank you.
Thanks you.
explanation is awesome.
If i have 2 same key in the map and if i delete with the key what would happen?
Impossible to have 2 same key.
@@quanlili1157 Are you sure, you've watched the video. The answer should be, "it would delete both keys". So, watch it and you will say at the end, WTF
@@TanGuven you can't have two same key in the same map.
@@TanGuven bro i tried it and the VScode only show the very last key if they are more than one with the same keys :)
Can you explain map delete with multiple empty objects as keys?
nice vide, finally i got it the difference and why it is useful. may i ask you what is that extension with the rocket down below that it says 2.3h? is like a focus mode activated?
nice video... very good explained :)
Thank you!
im confuse. i thought const cannot be reassigned. how can you use add and delete ?
At 0:52 how did you copy paste the second console.log???
it's a keyboard shortcut. on Mac if you hover over the line of code and press: shift , option , down arrow it'll duplicate.
Great video!
Thanks!
Can you make video on set key,values and entries methods?
How we can maintain set of unique objects? Javascript doesn't have equals method as Java to compare objects. right?
how to delete object inside of [1, 2, 3, 4, 6, {id: 7}]
i wanna achieve to delete object {id: 7 } with Set delete method,
i would be like this mySet.delete({id: 7})
is it right ?
You help me a lot. Thanks!
Hi, I have one query. how can we delete non-primitive values from set
Good lesson, thanks :)
i am a newbie on Js, please how do i get my vscode to show the console of my code
"vscode to show the console of my code" wtf??
may be you mean the node command, install nodejs on computer for executing js like that.
@@rokonzamann I think he means the integrated terminal in vscode
There is an extension called 'Code Runner'. Install it and you will see a 'play' icon to the extreme right . Just open terminal and results would be seen there .
How is it possible to change the const value?
Great tutorial but watch it at 2x speed!
add the map.get method explanation... good work!
How to delete non-primitive value from set?
great video
but why would i want to map an empty object to a value?
What's the color theme?
Nice .
Thank you for your explanation and examples they are very useful, I also read the doc but your explanation makes things a lot easier~ Great thanks, one sub for ya~
THANK YOU!!!!!
Great 👍you should make a series "data structures using js"
Great idea!
You forgot ‘get’ function in Map to get the value from the key like myMap.get(1) will output ‘one’.
Thank you!
Maps start here 8:13
I guess I don't get the value of a _set_ object. Surely it has to have more than just being unique. It'd be easy enough to write a method to remove redundant entries from an array. Where are the methods for doing set intersection, union, and subtraction, for instance? In _set theory,_ you use these operations all the time.
Thanks a lot
No problem.
Helpful
superrrrrrr!
Thanks!
Thankyou
Still couldn't understand what's the real life advantage of Map comparing to Object 🤔
2:06 It's amazing as a beginner trying to learn javascript, how often a decent video gets ruined because the teacher uses a term that is totally new without explaining it. So many people that know how to do something don't actually know how to tech things to beginners because they use terms that are more advanced.
Can I hug you ? 😍
if he doesnt want to be hugged hug me
console.log("Thanks!");
15:20 an