The Differences between ES6 Maps and Sets

  Рет қаралды 7,284

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

6 жыл бұрын

Maps are similar to Objects. Sets are similar to Arrays. Both provide you with Iterators which means that both can be used with a for...of loop.
Plain JavaScript Objects are not Iterable.
You can pass an Array directly into a Set using the constructor.
For Objects you need to loop through the properties and pass them to a Map one at a time.
Code GIST: gist.github.com/prof3ssorSt3v...

Пікірлер: 13
@rotrose7531
@rotrose7531 4 жыл бұрын
The idea using Set to remove duplicate is eye-opening! Thank you very much,.
@zeonleonel4684
@zeonleonel4684 5 жыл бұрын
Very nice explanation, Mr. Griffith!
@LeetCodeSimplified
@LeetCodeSimplified Жыл бұрын
Great explanation as always! Keep it up!
@chesterxp508
@chesterxp508 2 жыл бұрын
Another very cool tutorial!
@jacksonvinicius299
@jacksonvinicius299 9 ай бұрын
thanks man
@rungekutta5732
@rungekutta5732 4 жыл бұрын
Nice short video on the differences between Set/Array and Map/Object. I wanted to ask what are the purposes of using WeakMap and WeakSet? Only the advantage of garbage collection of the keys, am I right?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
That is one of the differences yes. Also, WeakSets are collections of objects only. They cannot contain arbitrary values of any type, like Sets do. With WeakMaps, unlike Maps, the keys are not enumerable.
@ProgrammingWithOsku
@ProgrammingWithOsku 3 жыл бұрын
Thx bro how about map array function ist the same map object what you talk about I'm little confuse hh
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Array is a datatype, just like Map and Set are datatypes. The Array datatype has a method called map. It is not the same as the Map datatype
@ProgrammingWithOsku
@ProgrammingWithOsku 3 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thx Bro you save my day because I thought .map() which loop the array is same as const map = new map() hhhhh thx so much.. can i ask how can i improve my skills in javascript to become senior developer
@rutwickgangurde3247
@rutwickgangurde3247 2 жыл бұрын
If you do an Array.from(names), you can convert the names Set back to an Array with duplicates removed. Quick way to eliminate duplicates from an Array.
@reportaccounthcc2463
@reportaccounthcc2463 2 жыл бұрын
Using a spread operator is a quicker/more modern way to do this
@muhamadizranovan1653
@muhamadizranovan1653 Жыл бұрын
so what's the point of using maps if maps overwrite the previous data too?, i think maps will be different
How to Chain JS Methods Together
7:34
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 5 М.
Iterable vs Enumerable in JavaScript
9:15
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 20 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 37 МЛН
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 10 МЛН
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 16 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 40 МЛН
JavaScript for..in Loops
7:24
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 43 М.
Understanding the Keyword THIS in JavaScript
13:59
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 8 М.
Custom Array Sorts in JavaScript
8:01
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 18 М.
Intro to JavaScript Symbols
9:46
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 14 М.
Maps vs. Objects in JavaScript - What's the Difference?
11:48
Practical Uses for Prototypes with Arrays
8:50
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 4,5 М.
Map, Set, WeakMap & WeakSet in JavaScript - Real use case
12:20
JavaScript Event Bubbling and Propagation
12:53
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 21 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 37 МЛН