Complete Guide to JS Sets: How They Work & When To Use Them

  Рет қаралды 16,692

Colt Steele

Colt Steele

Күн бұрын

This video covers one of the newer data structures in JS: the Set. We start by going over the basic syntax and Set methods, then we focus on specific use cases for Sets and WHY you would use them. Lastly we talk about the time complexity/Big O notation of common Set operations.
Find the notes here: www.notion.so/JavaScript-Sets...
If you're ready to launch your career as a software engineer, check out my job-guaranteed bootcamp with Springboard: springboard.com/workshops/sof...

Пікірлер: 105
@wasifnaqvi2213
@wasifnaqvi2213 4 жыл бұрын
I got a full time front end developer job because of you colt.... thanks a lot!!!
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
Congrats, Wasif! Tell more about it, if you have time! I love hearing from students who have benefited from the courses. You getting a job is 99% your own hard work, and maybe 1% my courses, so congrats on putting in all that work and time to make it happen!
@wasifnaqvi2213
@wasifnaqvi2213 4 жыл бұрын
@@ColtSteeleCode you are being modest, this was the second interview I attended and got placed in a product based company...never knew I had it in me....WDB paved my way into web development and from then on I kept on going and learning more and more.. currently I will be working on Vue js to create a UI... P.S - I left you an inmail on LinkedIn last month thanking for your awesome course which helped me to get an awesome job...maybe it did not reach you...I really hope all the students make it to their web development dreams
@aymanayman9000
@aymanayman9000 4 жыл бұрын
@@ColtSteeleCode if sets use hash how the items be ordered I mean if the search for item is big o of one then that's mean we use array not binary tree to implement it seems how items are ordered
@malaicristian360
@malaicristian360 4 жыл бұрын
So excited when your notification pops out. You rock Colt 👍
@yuhceeofficial
@yuhceeofficial 4 жыл бұрын
This is me too
@emmanuelbonilla9353
@emmanuelbonilla9353 4 жыл бұрын
I was en mail email then i saw there a new video and i stop everything and start watching it
@haikoerinkveld4242
@haikoerinkveld4242 2 жыл бұрын
Really like your videos Colt! I personally really appreciate the notes you add to your video's, I bookmark them all and even hard copy them. You deserve a lot more views on this video!
@deian85
@deian85 3 жыл бұрын
for the first example, [4,4,4,4,5] also returns size 2
@glassofchampagne
@glassofchampagne 4 жыл бұрын
Thanks for the video Colt! When I saw the title of this video it made my day, hell, it made my week! As always, thanks again
@keemeshrampersad8859
@keemeshrampersad8859 4 жыл бұрын
Awesome Colt... Love the way you explain everything... You make it look so easy... Love your work...
@bikabas
@bikabas 4 жыл бұрын
An absolute treat to watch your videos Colt. Keep up the good work.
@yatin1370
@yatin1370 Жыл бұрын
This was wonderful Colt, straight to the point and easy to understand!
@Hyp3rSp8c3
@Hyp3rSp8c3 4 жыл бұрын
Thank you, Colt! Great explanation on Set and their use cases.
@web3engineer
@web3engineer 11 ай бұрын
THE BEST EXPLANATION OF JS SETS. PERIOD. THANKS BRO!!!
@fakednicklv
@fakednicklv 4 жыл бұрын
Super useful video. Thanks Colt!
@GWebcob
@GWebcob 3 жыл бұрын
Thanks for including big O! It will help me a lot in my interview
@akarshpahariya6155
@akarshpahariya6155 4 ай бұрын
I figured out this one thing while working with sets that sets can have similar arrays inside them i.e. array with similar values can be stored within the same sets.
@RandomUserOnTheInterWebs
@RandomUserOnTheInterWebs 4 жыл бұрын
These are amazing guides, and the use of Notion is great.
@mustlearnmore4884
@mustlearnmore4884 4 жыл бұрын
Keep 'em coming, Colt -- consider your "experiment" a success!
@nuregal7699
@nuregal7699 3 жыл бұрын
Thanks, love the way you explain things.
@automatyk_
@automatyk_ 3 жыл бұрын
Awesome explanation. Really appreciate the practical examples.
@rinkeshgokulchandani4181
@rinkeshgokulchandani4181 4 жыл бұрын
I love these videos. Keep uploading Colt.💙
@yuhceeofficial
@yuhceeofficial 4 жыл бұрын
That feeling when you see a notification pop up for a new Colt Steele's KZfaq Video. 🕺🏻
@youcefmantas4944
@youcefmantas4944 Жыл бұрын
Thank You So Much We Really needed this video
@sagniksinha9494
@sagniksinha9494 4 жыл бұрын
can you please have a session on javascript Closures (that seems to be most confusing topic) and also Prototypes in js?
@ElFideoHomicida
@ElFideoHomicida 4 жыл бұрын
man... you're doing an excellente job. Thanks!
@sexyeur
@sexyeur 4 жыл бұрын
Cool, Colt! Thank you. Will be watching...
@emmanuelfabiani8435
@emmanuelfabiani8435 3 жыл бұрын
You're simply the best! Amazing at explaining things yet so humble and down to earth! I wish we were friends in real life. You must be a great human being to walk along the path of life
@ayushjain349
@ayushjain349 4 жыл бұрын
hey loved the video. just a small correction, u cant use set for checking 2 of one kind and 3 of another. it could be 4-1 combination as well. Thanks for the video.
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
Gahhh thanks for pointing that out. In my original solution I used a map along with a set to calculate the frequency of values. I have no idea why I thought this would work without the map! If only I could edit youtube videos after publishing them!
@vasilacheandrei4072
@vasilacheandrei4072 4 жыл бұрын
Good video Colt! Keep it up! ❤
@chameleonstreet5545
@chameleonstreet5545 2 жыл бұрын
Excellent, thank you!
@janice33135
@janice33135 4 ай бұрын
Thank you!!!! easy to understand :D
@alexjacksparrow476
@alexjacksparrow476 3 жыл бұрын
always love for you colt...
@LeBronJames-ns6to
@LeBronJames-ns6to 4 жыл бұрын
Awesome, love your explanations. Can you do one for every Javascript Data structure?
@joanclarke2724
@joanclarke2724 4 жыл бұрын
Your videos are amazing!
@russaanderson
@russaanderson 4 жыл бұрын
Thanks again - this is great stuff! I'd love it if you did a video on closures or recursion.
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
Hi Randy, thanks for the suggestions! I actually have a video on recursion out already, but I've added closures to the list *shudders at the mention of teaching closures*
@senecamanu6515
@senecamanu6515 4 жыл бұрын
I LEARN A SHIT TON FROM YOU, THANK YOU FOR YOUR HARD WORK!
@jatin_nagar
@jatin_nagar 4 жыл бұрын
Thanks colt 💕
@djRichyRichh
@djRichyRichh 3 жыл бұрын
thank you. great video.
@sundararajankarthik2947
@sundararajankarthik2947 3 жыл бұрын
hi colt, very good explaination,plz do more video's on javascript.
@danieldominguez287
@danieldominguez287 4 жыл бұрын
A video on explaining functional programming and practical use cases would be sweeeeeeeet
@skate211thrasher
@skate211thrasher 4 жыл бұрын
Dude .. Thanks a lot, I love your content even though I might know some of it (from your courses) :D But I enjoy how good you communicate any problem in a simple way so I end up learning new stuff. If I had the opportunity to choose a topic for any future video I hope it is "JS Observables".
@StephanDuToit
@StephanDuToit 10 ай бұрын
Excellent!
@Luxcium
@Luxcium 4 жыл бұрын
These small topics on JavaScript are truly amazing and appreciated you did also something nice with VSCODE recently you should consider doing the same thing as this video but on a topic related to NODE JS each and every tutorials are only about web server etc but events emitters or buffers or something exotic about NodeJs will be truly appreciated in fact the video of today is amazing and something similar should be covered inside NodeJs a small sub component of Node similar to today’s topic 😄
@RahulGupta04
@RahulGupta04 4 жыл бұрын
Love to see this kind of toturial, please can tell the difference b/w set and map
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
Hi Rahul, I've added it to the list! It'll probably be out next week or the following week depending on my schedule. Thanks for the suggestion!
@ronidey380
@ronidey380 3 жыл бұрын
Thank you so much❤️
@nikoman71326
@nikoman71326 3 жыл бұрын
best teacher on web
@muhammadhamza7114
@muhammadhamza7114 4 жыл бұрын
Thanks for the content Colt! I would like to request a video on "this" in javascript and how it differs in new versions from older ones. This is a topic which bugs the heck out of me and probably a lot of developers who want to get started with javascript. So a video would be nice in which you could explain how in different situations "this" works. Thanks again.
@Glittery_Magic
@Glittery_Magic 2 жыл бұрын
Do you understand it now? Took me a while to get but it clicks eventually
@mahmoudMokhtar94
@mahmoudMokhtar94 5 ай бұрын
Greet Explanation
@funguy29
@funguy29 4 жыл бұрын
you are the greatest
@Ahsana14
@Ahsana14 3 ай бұрын
Thank you
@AngleCoding
@AngleCoding 4 жыл бұрын
Do the “Map” data structure!!
@sourishdutta9600
@sourishdutta9600 4 жыл бұрын
Hi colt I am very much thankful to you.I have learned a lot from you tutorials on udemy. It will be very grateful if you discuss about meta programming concepts about symbols, proxy and use cases of that How actually these things works.Thanks a lot.
@babatundeololade6765
@babatundeololade6765 4 жыл бұрын
Colt, are you releasing any new course soon?
@nakulshyamkumar9122
@nakulshyamkumar9122 4 жыл бұрын
Could you do a code-along, please?
@ManontheBroadcast
@ManontheBroadcast 4 жыл бұрын
Could you explain please the use of the "~" character in the ArraySet.add method? ... Thanks ...
@tonystroemsnaes554
@tonystroemsnaes554 4 жыл бұрын
`~` is the symbol for "bitwise NOT". To understand what it does, and why it helps here, we have to look at how numbers work on computers. I'm sure you've heard about numbers being stored as binary 0011 0101, etc. Each of the digits are called a bit, and they're all added up as 2^n if 1 from the right side, so 0011 0101 would be 1+0+4+0+16+32+0+0 = 55. This is not entirely true, because with "signed" numbers (numbers than can be positive or negative, rather than just positive) The "most significant bit" (the bit furthest to the left) is reserved to denote the "sign" of a number (positive/negative). Now back to bitwise NOT, the operator simply flips all the bits from 1 to 0 and 0 to 1. So with my example above, ~0011 0101 becomes 1100 1010 = 2+8+64+128 = 202. This is only true if the number is an "8-bit unsigned integer", i.e. it is only made of 8 bits, it can't be negative, and it can't have a fraction (numbers after decimal point). However, if we took this same number and reserved the most significant bit for a sign, the NOT operator would give us a different results. ~0011 0101 = 1100 1010 = -1 * (2+8+64) = -70, The most significant bit, which previously became 128, now becomes "-", and just makes the whole number negative. We could do bitwise NOT on the negative number, and get a positive number too: ~(-70) = 55. Now, this isn't entirely true, because JavaScript and most other languages don't store negative numbers like that. Instead, they use something called two's compliment, which means it also adds 1 to the final result (though it doesn't affect the sign). Because of this, the number "-1" would be 1000 0000. The most significant bit (1) tells us it's negative, and adding all the numbers together, it just becomes 0. Then add 1, and you get -1 (because of the sign). This only happens for negative values, though, so 0000 0000 is still 0, and 0000 0001 is just 1. Funnily enough, this means we can always represent one more negative value than we can of positive values, regardless of how many bits we have. In this signed 8-bit example, we can store anything from -128 to 127. Now back to JS, the method `.indexOf()` will return the index of an element (a positive number or 0), or it will return -1 if it doesn't find any element. Since 0 is a reasonable answer if it finds something, that means you can't just do the normal `!value` to check if a something is exists or not. Instead, you have to either explicitly check if the index is -1, or if it is less than 0. BUT, knowing the bitwise NOT operator, you can be cheeky. Any NON-ZERO value in JS is treated as truthy, which means negative numbers are also truthy. So... if we NOT the index, "0" becomes -1, "1" becomes -2, "2" becomes -3, and "-1" becomes 0. The only value that becomes 0 after a bitwise NOT is -1, and it's -1 we want to check for, so we can just check if a value is not -1 by doing `!~value` !~(-2) => false !~(-1) => true !~(0) => false !~(1) => false !~(2) => false I know your message is relatively old, but hopefully this answered the question if someone else were wondering, or if you forgot about this and didn't look back. TL;DR: !~value is a dirty hack to check if a value is -1
@pranavchandra1662
@pranavchandra1662 4 жыл бұрын
I really love everything what you do! But please can you do some es6 videos bec I've been talking your course web Dev boot camp and from then things have been changed a lot :( and I don't know why but I just want to learn from you,so I really want to you do a video for es6 js like arrow functions , promises and async, await
@beedleChompz44
@beedleChompz44 3 жыл бұрын
what did you do with the chickens? Thanks for the video btw!
@micolashcage
@micolashcage 4 жыл бұрын
Hey, thanks for the video! I already took your react course but I'd love to see the tags input/intro to react video merely because of that nice tag animation. I'm aware of react sping, I just suck at fancy animations regardless. p.s. those are some really cute chicks
@zolomohan
@zolomohan 4 жыл бұрын
Hey Colt! Can You Do a Follow up on this video about that Hashing Function you talked about? You Said You'll do a separate video, So Please Don't forget that....
@NaveenS1109
@NaveenS1109 4 жыл бұрын
Hey Colt absolutely love your previous courses, coming to the point see Udemy is inundated with a lot (crazily a lot) of web development materials ( although mostly beginner materials, there is a need for advance web developer content ) but one major place l see where there is a lack of content is Java and related frameworks like spring boot, hibernate, JPA and also related topics like swagger. If you could have a course on those Java + related frameworks it will be one of a kind. Note: l'm not talking about basic Java course. I'm talking about course on Java based frameworks whose skills are in high demand for getting a job.
@sreekar_s
@sreekar_s 4 жыл бұрын
How to implement intersection and mutation observers?
@prateekthapa4127
@prateekthapa4127 4 жыл бұрын
Reverse-engineering a library or how to navigate through a library -- since most of our time is spent reading other people's code -- would be my suggestion. Thank you Colt.
@meganrodriguez1086
@meganrodriguez1086 4 жыл бұрын
FUCK. YES. SO. EXCITED. Thank you!!!
@nilen
@nilen 3 жыл бұрын
does anyone know if there is a yahtzee tutorial for javascript that would be great
@tkdevlop
@tkdevlop 4 жыл бұрын
Next video hashing function pls.
@bobbynicholson5329
@bobbynicholson5329 4 жыл бұрын
Colt I bought both your Web Dev and React courses. I see you are now taking suggestions. Please do a lesson on working with Stripe API, specifically the On-Demand Apps. I have been struggling with that one and can't really find good info anywhere. The API for On-Demand confuses me.
@kalekber
@kalekber 4 жыл бұрын
What is this ~ notation at the last example line 6 (if ~ this.values.indexOf...)
@RameenFallschirmjager
@RameenFallschirmjager 3 жыл бұрын
I'm here from your react udemy course!
@aymanayman9000
@aymanayman9000 4 жыл бұрын
Can any one please tell me how items in sets are ordered if search is big o of one then we use array not binary tree to implement it so items aren't ordered
@nicholasmaniccia1005
@nicholasmaniccia1005 4 жыл бұрын
do you have a Patreon or some service set up? I took your data structures Udemy course and you are a great teacher.
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
Hi Nicholas, I really appreciate the sentiment but I don't feel super comfortable setting a Patreon when I also create paid courses on Udemy. I know others do it, but it feels kind of slimy to me. Maybe I'm crazy. With that said, I've been working on a new project I'm very excited about. For anyone else reading this...don't worry I'm not leaving Udemy! Later this year I'll be launching a subscription website with tons of new shorter courses on topics like React Native, TypeScript, Vue, GraphQL, Advanced Data Structures/Algorithms, Testing, Angular, Observables, MongoDB, Node, Project Codealongs, and a bunch more. This will not replace my Udemy courses, but rather supplement the longer courses on Udemy with more modular, specific courses on important topics. To be successful on Udemy, most courses need to be 30-40 hour behemoths, but there are tons of topics that don't work well in that format. This new website will feature tons of courses and each month I'll add a new course. Students will get to suggest and vote on new course topics, and I'll be able to make them in a couple weeks rather than a couple months. I haven't decided on exact pricing yet, but it'll be somewhere around the price of a single udemy course on sale ($10-20). I'll also have "scholarships" available for students who can't afford to subscribe. All along the way, I'm going to continue posting new content to KZfaq too. Sorry for the long answer! This is something I'm really excited about.
@dakshsagar2839
@dakshsagar2839 4 жыл бұрын
@@ColtSteeleCode Awesome, really excited .
@wheres_bears1378
@wheres_bears1378 4 жыл бұрын
So I guess sets would be good to store unique Ids etc ?
@tomvanhuffel
@tomvanhuffel 4 жыл бұрын
the isFullHouse(dice) will also be 'true' if you have 4 of a kind ;)
@lauris5275
@lauris5275 2 жыл бұрын
I been using sets only if i need to remove duplicates from array/string.
@rampandey191
@rampandey191 4 жыл бұрын
How about a video about JavaScript generators
@boopfer387
@boopfer387 3 жыл бұрын
I like baby Ducks more! Make a video about sorting / filtering - table data (doesn't have to be a table... seems like most of the big websites including Amazon are moving away from
@Luxcium
@Luxcium 4 жыл бұрын
I am really disappointed a lot and I truly hated that... What you told me last time made me feel bad... I was doing a super nice comment but you have been scared to read it because the notification on your cell phone... so this time I have a even more POSITIVE message than last time for you ❤️... Keep up the good work, you put so much effort and energy and you are making high quality videos, we appreciate your amazing videos (I am talking for myself but said WE because reading the comments I know I am not alone) it’s always a pleasure to see how interesting and well made your videos are and all the effort you put in the course side notes... I hope one day you will have all of them in your own website (maybe receiving advertisement revenues for your own references web site build over time when your posting videos) The site your using right now to publish your notes is very high quality I am impatient for your next movie and hope it could be about VSCODE because I think it can turn into a lot of views and new subscribers (I am at the very beginning of the video 0:09 and I therefore won’t comment on your call to action this week) I am hoping to see something about TypeScript as soon as you are comfortable about it and ready to do so ... chers 🥂 and keep up the good work you will be impressed by where you will end up with your channel because your stats will go in the roof faster than you can imagine with such a great work 📈 - Edit : ho you literally said please subscribe at 0:10 haha just after I pressed play at the very beginning of the video :-) I wish I could subscribe more but I will give it a Blue Thumb right now !!!
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
YOU GOT ME AGAIN. Once again, I was braced for something horrible! Thanks for the nice note instead. I'm actually working on my own website which will offer a bunch of small courses. It'll be out sometime later this year! I'm very excited about it. Let me know if you have any topic requests for youtube videos!
@Luxcium
@Luxcium 4 жыл бұрын
Colt Steele If you need help to build your website there is an amazing bootcamp on UDEMY that will make you all set up for success it’s an advanced web developer the part that you will love the most would probably be the advanced CSS since it’s something that would easily benefit your react tutorials ... anyway if you can find ideas from that CSS teacher (but it’s also important to stay your self and not copy the style of that young talent) haha 🤣 I feel like I will watch again I still need to improve my front end skills LoL 😂 Keep up your amazing work and make sure you enroll as many people as you can (trough subscriptions and more) because it’s sure you will be able to get to the level where it’s getting you interesting income from KZfaq I which you that because it’s surely more work than we can imagine to be able to do new videos on such a schedule 😄
@Luxcium
@Luxcium 4 жыл бұрын
Colt Steele you MUST mention my name if every you say you are doing TypeScript because of the request of someone in the comments or something and why not including a review of my VSCODE colour theme if you do a video on that great IDE (It’s called Pop N' Lock Theme by Luxcium ✨) it’s on the market place it has been trending in the top FIRST extension for one week a month ago it’s designed with TypeScript in mind and JavaScript also 😄
@topgpodcast777
@topgpodcast777 3 жыл бұрын
Hi my js code is not working in chrome even though it is enabled in the browser and the code is right I am have bought your Bootcamp course
@nilen
@nilen 3 жыл бұрын
12:00 but [1,4,4,4,4] would also work?
@ABoZain1
@ABoZain1 Жыл бұрын
if you called isFullHouse with [1,2,2,2,2] as a parameter it would return true and if I got it right that wasn`t a full house , i suggest it would be better to iterate and check because no vanilla set method will do it, decent video by the way🙏
@vb97542
@vb97542 4 жыл бұрын
A video on higher order functions(map, filter, reduce...) and their use cases would be awesome...
@boopfer387
@boopfer387 3 жыл бұрын
love the baby chicks! Ha! Thank you for this video!
@dianakechyants565
@dianakechyants565 2 жыл бұрын
what about Map
@thomasmcguire3294
@thomasmcguire3294 4 жыл бұрын
Since you've done Sets, it's only right to do Map as well.
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
That one will be the next JS video I do, probably next week or the following week! Thanks for the suggestion!
@historyArena1
@historyArena1 3 жыл бұрын
@@ColtSteeleCode you haven't done maps yet :(((
@francisseneve2934
@francisseneve2934 4 жыл бұрын
React Native course
@johnjohn7023
@johnjohn7023 4 жыл бұрын
here is a detailed info on Sets and Maps github.com/nzakas/understandinges6/blob/master/manuscript/07-Sets-And-Maps.md
@szeredaiakos
@szeredaiakos 10 ай бұрын
So Sets are like arrays in IE6 (if i recall correctly) Also ... tho yr examples are solid, but abusing a feature of a data type for business logic is probably a very bad idea.
@KaiAble0601
@KaiAble0601 4 жыл бұрын
it’s pretty much the same as Java!
@noobtrader454
@noobtrader454 4 жыл бұрын
i just dont get javascript like could you call a function anything you want ?
@Knards
@Knards 4 жыл бұрын
Was brought up on a farm a very long time ago. Miss the sound of baby chicks
@ColtSteeleCode
@ColtSteeleCode 4 жыл бұрын
Those noises are very adorable! It's not so adorable when they get too hot and start their distress chirps :( We've had a heatwave here, and I don't have air conditioning which made things difficult! I had to move my one tiny portable AC unit into the room with the chickens, which means my office and bedroom at impossibly hot! The things I do for those baby chicks...
The Complete Guide to JS Symbols ES6
12:18
Colt Steele
Рет қаралды 52 М.
You Should Use Maps and Sets in JS
14:28
Syntax
Рет қаралды 8 М.
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 112 МЛН
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 3,7 МЛН
small vs big hoop #tiktok
00:12
Анастасия Тарасова
Рет қаралды 21 МЛН
Graph Search Algorithms in 100 Seconds - And Beyond with JS
10:30
Vectors in Java: The 1 Situation You Might Want To Use Them
16:13
Coding with John
Рет қаралды 76 М.
Improve Your Code With ESLint + VsCode + Airbnb Styleguide
13:19
Colt Steele
Рет қаралды 51 М.
Weak References, Reachability, WeakSets, and WeakMaps
15:54
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 3,4 М.
Master JavaScript Array Reduce Method In 10 Minutes
10:51
Colt Steele
Рет қаралды 7 М.
Use Maps more and Objects less
5:45
Steve (Builder.io)
Рет қаралды 87 М.
Maps vs. Objects in JavaScript - What's the Difference?
11:48
JavaScript Array Mastery: Tips, Tricks & Best Practices
1:02:49
Envato Tuts+
Рет қаралды 18 М.
Javascript Window vs. Document vs. Screen WHAT??
9:38
Colt Steele
Рет қаралды 23 М.
cute mini iphone
0:34
승비니 Seungbini
Рет қаралды 5 МЛН
Simple maintenance. #leddisplay #ledscreen #ledwall #ledmodule #ledinstallation
0:19
LED Screen Factory-EagerLED
Рет қаралды 2,7 МЛН