You Should Use Maps and Sets in JS

In this video CJ talks about the scenarios when it is better to use Maps and Sets instead of Objects and Arrays in JavaScript.


00:00 Intro
01:09 The problem with Objects
02:41 When to use a Map
03:07 How to use Map
04:34 Create a Map from an Object
04:59 Object Keys are Strings
05:59 Create a Map from an Array
07:02 Map methods are nice
07:45 JSON.stringify a Map
08:53 Sets
09:15 The problem with Array.includes
10:36 Making a Set with an Object
11:50 Create a Set from an Array
12:23 Sets and Duplicate Values
12:58 Set methods on MDN
13:21 Thanks for watching

Listen to episode 689 on Syntax: https://syntax.fm/show/689/you-should-be-using-javascript-maps-and-sets

Read about Map on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

Read about Set on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set