The set is great only under few conditions: - you don't do frequent addition, because each element has a calculated index - you can't update existed elements - just use Map - you can't refer after index `array[index]` - just use Array Set is something like an object `{}` with built in an iterator
@yobebill1234Күн бұрын
everything is an object jerry.
@designerjehovah44533 күн бұрын
Glad to have you back Jack!!
@jherr3 күн бұрын
Nice to be back from vacation.
@mounis3 күн бұрын
Wake up babe, new Jack Herrington video just dropped.
@acrosstundras2 күн бұрын
When it comes to performance, the answer is, more often than not, "it depends". For example, in some situations, array lookup will use CPU cache, whereas set will not, resulting in worse performance counterintuitively.
@mahmoud-d223 күн бұрын
Happy new year Jack :)
@rogerscriptКүн бұрын
New Year, but the same awesome quality of your videos Jack! Thank you to be back!
@NaserPapi-x7z2 күн бұрын
Excellent Exploration; I really appreciate your technique for teaching this fascinating topic. Personally, I enjoyed the performance part and your demo of the O-one vs. O-N lookup. Thanks for this great sharing.
@ahoy12 күн бұрын
I used Sets for the first time a few month ago, they're great. Having union/difference/etc methods built right in is great
@RossOlsonDotCom3 күн бұрын
Great tight overview of this! The one thing I’m missing is the types that are returned. It looks like some of the set operations will return arrays, but some could return sets. It would be great to know which is coming back.
@shinebayar2 күн бұрын
Btw performance difference is negligible if you're working with small data set like under a thousand or something. Because of the array values are stored next to each other in the memory and it's faster to lookup them if the entire array can fit in the cpu cache.
@yamelamadorfernandez74162 күн бұрын
Honestly I've used 30% of the Set features, watching this video reformatted my brain, now I realize that Set is very powerful and closer to Array functionality than Map.
@JoshMarom-zx9mv2 күн бұрын
Great content as usual
@dkazmer23 күн бұрын
Best video on Set I've seen
@alexlohr73662 күн бұрын
The Set in JS is a hash set with fast collision handling under the hood. By the way, there is a solid-primitive for a reactive Set that you'll like.
@MohammedWaseemAnjum2 күн бұрын
Thank you sir you are awesome as usual!
@aaronstarling98373 күн бұрын
Awesome information!
@reneheijdens8444Күн бұрын
Great video! I've been using Set to generate arrays with unique values, but I never realized its full potential until now. 😅 Quick question: How do you use Set effectively with objects? Since the uniqueness constraint relies on object references, does that mean it only works if the objects reference the exact same memory location? Also, is it possible to extend Set functionality to perform operations like union, intersection, and difference when dealing with objects? Would love to hear your thoughts or see examples!
@jherrКүн бұрын
You can just do something like: const keysA = new Set(Object.keys(a)); const keysB = new Set(Object.keys(b)); keysA.union(keysB); keysA.symmetricDifference(keysB); // etc. You could do the same thing with Object.values(). Depends on your use case.
@josersleal2 күн бұрын
even I could understand that at first at 1.5x speed. well done Sir. On notebooks, there's also microsoft new offering: polyglot notebooks extension. you can use multiple languages in the same notebook and share variables between them. create diagrams and more. no typescript yet though.
@jherr2 күн бұрын
Ooof, that last sentence is a killer. No TypeScript? From Microsoft? Booo... Otherwise, sign me up!
@lastink4445 сағат бұрын
I'm actually more surprised/impressed by the jupyter notebook here
@daxdivv3 күн бұрын
How do you get those auto completions at 0:41?
@lakshmanshankar3 күн бұрын
I'm not sure what that was but it looks like warp terminal.
@dannrcstr3 күн бұрын
First you must have a MacOS, then install the ZSH terminal (version 5.8 or greater), then install and configure the zsh-autocomplete plugin
@sikritidakua3 күн бұрын
I think it was something called `fig sh` I used it in the past but I removed it later, it was very annoying for me
@dannrcstr3 күн бұрын
@@sikritidakua Fig has been discontinued
@sikritidakua3 күн бұрын
@ yeah its Amazon Q cli or something i dont remember correctly but if u search fig sh it will come
@adrian342343 күн бұрын
Great video I really like Set a lot! Can it be used in js already?
@jherr3 күн бұрын
100%.
@youarethecssformyhtml3 күн бұрын
They're so old actually (released before 2016) so yeah
@adrian342342 күн бұрын
@@youarethecssformyhtml So why is there more noise about it now? I'm curious
@youarethecssformyhtml2 күн бұрын
@@adrian34234 no idea
@dkazmer22 күн бұрын
@@adrian34234 cuz clearly nobody knows about it still
@mannuelf3 күн бұрын
Great great great 🤘🚀
@Mizax22Сағат бұрын
The translation in French is truly top-notch 🎉
@MrJettann3 күн бұрын
Do we need use usecallback on functions passed to set?
@jherr3 күн бұрын
Yes. You want references to functions in React to be controlled, which is what useCallback does, regardless of where you store them. And in particular with Set, you are using the memory location of the function as the unique key, so, yes, use useCallback.
@Ivan-wm6gm2 күн бұрын
javascript team should really add priority queue
@deatho0ne5873 күн бұрын
O(1) is not always faster than O(N) since you need to care about things like creation, deletion, etc... times. The testing of the speed is kind of bad to be fair. Data is normally never in such a simple order or just number. I do like the examples of some set comparisons to be honest.
@codehan3 күн бұрын
Thanks! 🎉
@flydown194019 сағат бұрын
name of vscode theme?
@jherr19 сағат бұрын
Night Wolf (black)
@bryson2662Күн бұрын
What is the point of Set.entries?
@jherrКүн бұрын
Compatability with a family of data structures. Map, Set and arrays all support `entries` directly. And Object.entries gets you entries for an object.
@nuwanthuduwage68693 күн бұрын
Cool!
@ggnova85813 күн бұрын
Theme?
@jherr3 күн бұрын
Night Wolf (black). Always listed in the description.
@ggnova85813 күн бұрын
@@jherrmy bad I didn’t see that
@jherr3 күн бұрын
@@ggnova8581 No worries. Just referencing it for future commenters. (Actually I shouldn't, more comments is good. Hahahah.)
@danser_theplayer01Күн бұрын
A few notes if you care about performance (maybe you're doing servers or science): - Sets are bad at iteration as they use generators which is actually very slow compared to a *for* loop. The same can be said about any object that let's you use *for of* or spread *...* of values, because those are also generators (... isn't always though). Generators and callback methods like forEach() are inefficient (at least generators bring some neat special functionality), and fall off hard after a certain point. It's especially true when generators yield other generators.
@ryosukekureha48733 күн бұрын
잭형님❤
@ryankdavidson3 күн бұрын
Monday morning Jack Attack 💥. TIL Jupyter can be used with JS via Deno, great side takeaway from this.
@nro3372 күн бұрын
Great video for performance!
@M1a2n3o432 күн бұрын
Wtf you can run javascript code in a ipynb file?
@SrAzionКүн бұрын
so normally it depends on the algorithms
@nathanalbergКүн бұрын
who comes up with these names?.... `set.difference` should be `set.without` and `set.symmetricDifference` should be `set.difference`... i mean... wtf. symmetricDifference?
@jherrКүн бұрын
Mathematicians. Difference and Symmetric Difference are well defined terms in Set Theory.
@LutherDePapierКүн бұрын
At 8:36, when a developer accidentally creates an array of 300000 values, JavaScript as a language should have a built-in mechanism to turn that insanity into a Set. ECMA team if you're listening.
@jherrКүн бұрын
Hahaha. That would be terrifying. There are key semantic differences between the two.
@WCanyon3 күн бұрын
good video -- you're talking kinda fast in here though
@thearcticmonkey3 күн бұрын
Decrease video speed
@jherr3 күн бұрын
And here I think I'm always talking too slow. Hahaha. Yes, decrease (or increase) playback speed to suit.