In this video we will look at some of the new data structures. ES6 Introduced Maps and Sets to JavaScript. Understand difference between JavaScript objects and Maps and Sets and Arrays.
Пікірлер: 96
@felipeog3 жыл бұрын
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
@b7otato4 жыл бұрын
7:50 - map
@qatadd83133 жыл бұрын
Man I Thank You Strongly For Make Everything Crystal Clear..
@Karlponken3 жыл бұрын
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.
@rahuls3314 жыл бұрын
Your coding flow is nice. The smooth use of shortcuts and line movements are fantastic.
@javascriptmastery4 жыл бұрын
Glad you think so!
@deepakkaithwas82813 жыл бұрын
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.
@frankliva74382 жыл бұрын
the way youre explaining is so different. such clarity
@LiveEveryMoment_WithLOVE.2 жыл бұрын
Wow, no more search abt JS Set n Map, thank U so much Bro!👍
@vijayyadavs3 жыл бұрын
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
@teachhelphotline6783 жыл бұрын
Thank you for this video!!! I finally know how to use a Map!!! :D
@benabernethy14052 жыл бұрын
Thank you. Really appreciate this vid. Subbed!
@veermetri054 жыл бұрын
Really nice explanation, thanks you. I expected to also learn Map.get.
@bridgetfitzgerald76562 жыл бұрын
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.
@lucahighton7648 Жыл бұрын
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.
@anj000 Жыл бұрын
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.
@lucahighton7648 Жыл бұрын
@@anj000 I have used objects as keys before. it is useful to work with data from a relational database
@JimmyKama Жыл бұрын
@@anj000 What's the point of making JS harder and convulated? Makes no sense. btw it's no private matter fater all...
@kiwi-Centaur2 жыл бұрын
thaks for this awesome tutorial, very helpful, cleared my confusion about sets and maps. thnks
@samueltorres24852 жыл бұрын
A video with more practical examples would be great! Nice video!
@TomasSowellIsGreat2 жыл бұрын
This is a great introduction!!
@saifulislamkhan64144 жыл бұрын
Awesome bro. Please keep it up.
@CastleShield4 жыл бұрын
Well explained, thank you.
@javascriptmastery4 жыл бұрын
Thanks!
@rajeevpurohit23 Жыл бұрын
Clear and concise! But you forgot to mention the get methods to get the value after setting
@lagiator5 жыл бұрын
thanks, keep uploading!
@javascriptmastery5 жыл бұрын
Thank you soo much! As I'm just starting out, it really means a lot!
@nan37763 жыл бұрын
You help me a lot. Thanks!
@Capicuaman5 жыл бұрын
Great video, thank you.
@javascriptmastery5 жыл бұрын
Thanks you.
@VishalGupta-jsdev2 жыл бұрын
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
@danielmatei68584 жыл бұрын
Good lesson, thanks :)
@longnhat6405 Жыл бұрын
nicely problem solution approach! keep it up
@Nickdondo2 жыл бұрын
lol I needed this video 5 hours ago before my technical assessment.
@fernandoesparragoza87653 жыл бұрын
Also, you can use get() to get the value from a Map property by its key.
@kasra8106 Жыл бұрын
Probably the most important one lol
@nicholasc.59447 ай бұрын
yea i was skipping back and forth looking for where he referenced the map value lol
@ihtshammir3733Ай бұрын
Simple spot on.
@ilearnwithstar4389 Жыл бұрын
explanation is awesome.
@faultfinderx Жыл бұрын
Thank you!
@addicted2headway2 жыл бұрын
Please make a more videos on Javascript. Which will help to solve Data structures and algorithms problems
@fuka96763 жыл бұрын
great video
@oncoding4520 Жыл бұрын
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?
@luanmotta49064 жыл бұрын
Great video!
@javascriptmastery4 жыл бұрын
Thanks!
@zexsen854 жыл бұрын
nice video... very good explained :)
@javascriptmastery4 жыл бұрын
Thank you!
@blyfo2 жыл бұрын
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
@girlandhercomputer72044 жыл бұрын
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~
@sanjanak75983 жыл бұрын
Nice .
@knightfallgame3 жыл бұрын
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?
@anaghasalvi83644 жыл бұрын
Helpful
@valikonen4 жыл бұрын
You miss very important aspect, how to loop over them.
@Samuel-wi1dh3 жыл бұрын
looping over an object isn't specific to Maps/Sets
@zacharywallace8067 Жыл бұрын
Deconstruct into an array and loop over said array [...myMap].forEach(value => {...})
@lutfiikbalmajid Жыл бұрын
forEach
@s1a2i3l4u55 жыл бұрын
Thanks a lot
@javascriptmastery5 жыл бұрын
No problem.
@anilkatakam27383 жыл бұрын
Can you explain map delete with multiple empty objects as keys?
@aamirsuleman98153 жыл бұрын
add the map.get method explanation... good work!
@sanchit88184 жыл бұрын
Great tutorial but watch it at 2x speed!
@saputrauta095 ай бұрын
Thankyou
@think_cafeАй бұрын
Can you make video on set key,values and entries methods?
@ankitaaaaaaa253 жыл бұрын
Great 👍you should make a series "data structures using js"
@javascriptmastery3 жыл бұрын
Great idea!
@bobbysilver272 Жыл бұрын
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.
@pravinchukkala545 Жыл бұрын
Hi, I have one query. how can we delete non-primitive values from set
@meghalbisht67684 жыл бұрын
superrrrrrr!
@javascriptmastery4 жыл бұрын
Thanks!
@TanGuven4 жыл бұрын
If i have 2 same key in the map and if i delete with the key what would happen?
@quanlili11574 жыл бұрын
Impossible to have 2 same key.
@TanGuven4 жыл бұрын
@@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
@snehashischattopadhyay95194 жыл бұрын
@@TanGuven you can't have two same key in the same map.
@ilovepizza82632 жыл бұрын
@@TanGuven bro i tried it and the VScode only show the very last key if they are more than one with the same keys :)
@vaibhavsharma39553 жыл бұрын
How we can maintain set of unique objects? Javascript doesn't have equals method as Java to compare objects. right?
@pie13372 жыл бұрын
im confuse. i thought const cannot be reassigned. how can you use add and delete ?
@patrikshane79812 жыл бұрын
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 ?
@elenavetisyan18262 жыл бұрын
How is it possible to change the const value?
@davivify2 жыл бұрын
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.
@Tony.Nguyen137 Жыл бұрын
At 0:52 how did you copy paste the second console.log???
@mikeynavarro3195 Жыл бұрын
it's a keyboard shortcut. on Mac if you hover over the line of code and press: shift , option , down arrow it'll duplicate.
@evidnelz36284 жыл бұрын
i am a newbie on Js, please how do i get my vscode to show the console of my code
@r0mankon3 жыл бұрын
"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.
@GooseGumlizzard3 жыл бұрын
@@r0mankon I think he means the integrated terminal in vscode
@revatib9083 жыл бұрын
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 .
@aswinbudhathoki630023 күн бұрын
You forgot ‘get’ function in Map to get the value from the key like myMap.get(1) will output ‘one’.
@jemesmemes90263 жыл бұрын
Maps start here 8:13
@anonymousmasungsong66853 жыл бұрын
What's the color theme?
@leg3ndtariq4 жыл бұрын
Can I hug you ? 😍
@DRKongo-vi8ok3 жыл бұрын
if he doesnt want to be hugged hug me
@nhatkhoaphan9713 жыл бұрын
but why would i want to map an empty object to a value?
@chandiniudaykumar6628 Жыл бұрын
How to delete non-primitive value from set?
@iiimiiim4 жыл бұрын
console.log("Thanks!");
@mmrm3302 Жыл бұрын
Still couldn't understand what's the real life advantage of Map comparing to Object 🤔