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

Поділитися
Вставка
  • Опубліковано 22 жов 2024

КОМЕНТАРІ • 106

  • @wasifnaqvi2213
    @wasifnaqvi2213 5 років тому +72

    I got a full time front end developer job because of you colt.... thanks a lot!!!

    • @ColtSteeleCode
      @ColtSteeleCode  5 років тому +16

      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 5 років тому +8

      @@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 5 років тому

      @@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 5 років тому +28

    So excited when your notification pops out. You rock Colt 👍

    • @yuhceeofficial
      @yuhceeofficial 5 років тому +1

      This is me too

    • @emmanuelbonilla9353
      @emmanuelbonilla9353 5 років тому +2

      I was en mail email then i saw there a new video and i stop everything and start watching it

  • @deian85
    @deian85 4 роки тому +3

    for the first example,
    [4,4,4,4,5] also returns size 2

  • @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

  • @web3engineer
    @web3engineer Рік тому

    THE BEST EXPLANATION OF JS SETS. PERIOD. THANKS BRO!!!

  • @akarshpahariya6155
    @akarshpahariya6155 8 місяців тому +1

    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.

  • @GWebcob
    @GWebcob 3 роки тому

    Thanks for including big O! It will help me a lot in my interview

  • @haikoerinkveld4242
    @haikoerinkveld4242 3 роки тому +1

    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!

  • @yatin1370
    @yatin1370 Рік тому

    This was wonderful Colt, straight to the point and easy to understand!

  • @glassofchampagne
    @glassofchampagne 5 років тому +2

    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

  • @mustlearnmore4884
    @mustlearnmore4884 5 років тому +1

    Keep 'em coming, Colt -- consider your "experiment" a success!

  • @yuhceeofficial
    @yuhceeofficial 5 років тому +1

    That feeling when you see a notification pop up for a new Colt Steele's UA-cam Video. 🕺🏻

  • @keemeshrampersad8859
    @keemeshrampersad8859 5 років тому +1

    Awesome Colt... Love the way you explain everything... You make it look so easy... Love your work...

  • @bikabas
    @bikabas 5 років тому

    An absolute treat to watch your videos Colt. Keep up the good work.

  • @ayushjain349
    @ayushjain349 5 років тому +2

    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  5 років тому +3

      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!

  • @Hyp3rSp8c3
    @Hyp3rSp8c3 5 років тому

    Thank you, Colt! Great explanation on Set and their use cases.

  • @danieldominguez287
    @danieldominguez287 5 років тому

    A video on explaining functional programming and practical use cases would be sweeeeeeeet

  • @automatyk_
    @automatyk_ 3 роки тому

    Awesome explanation. Really appreciate the practical examples.

  • @fakednicklv
    @fakednicklv 5 років тому +1

    Super useful video. Thanks Colt!

  • @nuregal7699
    @nuregal7699 4 роки тому

    Thanks, love the way you explain things.

  • @RandomUserOnTheInterWebs
    @RandomUserOnTheInterWebs 5 років тому

    These are amazing guides, and the use of Notion is great.

  • @sundararajankarthik2947
    @sundararajankarthik2947 3 роки тому

    hi colt, very good explaination,plz do more video's on javascript.

  • @sagniksinha9494
    @sagniksinha9494 5 років тому +1

    can you please have a session on javascript Closures (that seems to be most confusing topic) and also Prototypes in js?

  • @nikoman71326
    @nikoman71326 3 роки тому

    best teacher on web

  • @youcefmantas4944
    @youcefmantas4944 Рік тому

    Thank You So Much We Really needed this video

  • @russaanderson
    @russaanderson 5 років тому

    Thanks again - this is great stuff! I'd love it if you did a video on closures or recursion.

    • @ColtSteeleCode
      @ColtSteeleCode  5 років тому +1

      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 5 років тому

    I LEARN A SHIT TON FROM YOU, THANK YOU FOR YOUR HARD WORK!

  • @Luxcium
    @Luxcium 5 років тому

    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 😄

  • @muhammadhamza7114
    @muhammadhamza7114 5 років тому

    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

  • @RahulGupta04
    @RahulGupta04 5 років тому

    Love to see this kind of toturial, please can tell the difference b/w set and map

    • @ColtSteeleCode
      @ColtSteeleCode  5 років тому +1

      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!

  • @beedleChompz44
    @beedleChompz44 3 роки тому

    what did you do with the chickens? Thanks for the video btw!

  • @LeBronJames-ns6to
    @LeBronJames-ns6to 4 роки тому

    Awesome, love your explanations. Can you do one for every Javascript Data structure?

  • @ElFideoHomicida
    @ElFideoHomicida 5 років тому

    man... you're doing an excellente job. Thanks!

  • @ManontheBroadcast
    @ManontheBroadcast 5 років тому +3

    Could you explain please the use of the "~" character in the ArraySet.add method? ...
    Thanks ...

    • @tonystroemsnaes554
      @tonystroemsnaes554 4 роки тому +2

      `~` 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

  • @zolomohan
    @zolomohan 5 років тому

    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....

  • @chameleonstreet5545
    @chameleonstreet5545 2 роки тому

    Excellent, thank you!

  • @alexjacksparrow476
    @alexjacksparrow476 3 роки тому

    always love for you colt...

  • @skate211thrasher
    @skate211thrasher 5 років тому

    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".

  • @jatin_nagar
    @jatin_nagar 5 років тому

    Thanks colt 💕

  • @janice33135
    @janice33135 8 місяців тому

    Thank you!!!! easy to understand :D

  • @mznunaya
    @mznunaya 2 місяці тому

    You da man Colt

  • @prateekthapa4127
    @prateekthapa4127 5 років тому

    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.

  • @djRichyRichh
    @djRichyRichh 3 роки тому

    thank you. great video.

  • @bobbynicholson5329
    @bobbynicholson5329 5 років тому

    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.

  • @babatundeololade6765
    @babatundeololade6765 5 років тому

    Colt, are you releasing any new course soon?

  • @RameenFallschirmjager
    @RameenFallschirmjager 3 роки тому +1

    I'm here from your react udemy course!

  • @StephanDuToit
    @StephanDuToit Рік тому

    Excellent!

  • @rinkeshgokulchandani4181
    @rinkeshgokulchandani4181 5 років тому

    I love these videos. Keep uploading Colt.💙

  • @nicholasmaniccia1005
    @nicholasmaniccia1005 5 років тому +2

    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  5 років тому +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 UA-cam too. Sorry for the long answer! This is something I'm really excited about.

    • @dakshsagar2839
      @dakshsagar2839 5 років тому

      @@ColtSteeleCode Awesome, really excited .

  • @pranavchandra1662
    @pranavchandra1662 5 років тому

    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

  • @nilen
    @nilen 3 роки тому +1

    does anyone know if there is a yahtzee tutorial for javascript that would be great

  • @ronidey380
    @ronidey380 4 роки тому

    Thank you so much❤️

  • @kalekber
    @kalekber 5 років тому

    What is this ~ notation at the last example line 6 (if ~ this.values.indexOf...)

  • @Luxcium
    @Luxcium 5 років тому

    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  5 років тому

      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 5 років тому

      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 UA-cam 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 5 років тому

      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 😄

  • @joanclarke2724
    @joanclarke2724 5 років тому

    Your videos are amazing!

  • @AngleCoding
    @AngleCoding 5 років тому

    Do the “Map” data structure!!

  • @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🙏

  • @vasilacheandrei4072
    @vasilacheandrei4072 5 років тому

    Good video Colt! Keep it up! ❤

  • @mahmoudMokhtar94
    @mahmoudMokhtar94 9 місяців тому

    Greet Explanation

  • @micolashcage
    @micolashcage 5 років тому

    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

  • @meganrodriguez1086
    @meganrodriguez1086 5 років тому

    FUCK. YES. SO. EXCITED. Thank you!!!

  • @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

  • @nakulshyamkumar9122
    @nakulshyamkumar9122 5 років тому

    Could you do a code-along, please?

  • @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

  • @NaveenS1109
    @NaveenS1109 5 років тому

    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.

  • @sourishdutta9600
    @sourishdutta9600 5 років тому

    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.

  • @tomvanhuffel
    @tomvanhuffel 4 роки тому

    the isFullHouse(dice) will also be 'true' if you have 4 of a kind ;)

  • @wheres_bears1378
    @wheres_bears1378 4 роки тому

    So I guess sets would be good to store unique Ids etc ?

  • @sreekar_s
    @sreekar_s 5 років тому

    How to implement intersection and mutation observers?

  • @lauris5275
    @lauris5275 2 роки тому

    I been using sets only if i need to remove duplicates from array/string.

  • @Ahsana14
    @Ahsana14 6 місяців тому

    Thank you

  • @rampandey191
    @rampandey191 5 років тому

    How about a video about JavaScript generators

  • @aymanayman9000
    @aymanayman9000 5 років тому

    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

  • @funguy29
    @funguy29 5 років тому

    you are the greatest

  • @nilen
    @nilen 3 роки тому

    12:00 but [1,4,4,4,4] would also work?

  • @tkdevlop
    @tkdevlop 5 років тому

    Next video hashing function pls.

  • @szeredaiakos
    @szeredaiakos Рік тому

    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.

  • @noobtrader454
    @noobtrader454 5 років тому

    i just dont get javascript like could you call a function anything you want ?

  • @boopfer387
    @boopfer387 3 роки тому

    love the baby chicks! Ha! Thank you for this video!

  • @thomasmcguire3294
    @thomasmcguire3294 5 років тому +2

    Since you've done Sets, it's only right to do Map as well.

    • @ColtSteeleCode
      @ColtSteeleCode  5 років тому +2

      That one will be the next JS video I do, probably next week or the following week! Thanks for the suggestion!

    • @historyArena1
      @historyArena1 4 роки тому

      @@ColtSteeleCode you haven't done maps yet :(((

  • @francisseneve2934
    @francisseneve2934 5 років тому +6

    React Native course

  • @KaiAble0601
    @KaiAble0601 5 років тому

    it’s pretty much the same as Java!

  • @Knards
    @Knards 5 років тому +1

    Was brought up on a farm a very long time ago. Miss the sound of baby chicks

    • @ColtSteeleCode
      @ColtSteeleCode  5 років тому +1

      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...

  • @tt._.7857
    @tt._.7857 2 місяці тому

    This was such a good explanation, on top of that we get a vid of some adorable ass chicks. Yeah this is my new favourite channel

  • @johnjohn7023
    @johnjohn7023 5 років тому

    here is a detailed info on Sets and Maps github.com/nzakas/understandinges6/blob/master/manuscript/07-Sets-And-Maps.md

  • @vb97542
    @vb97542 5 років тому +1

    A video on higher order functions(map, filter, reduce...) and their use cases would be awesome...