I'm just looking into ES2015, and coming up to Maps, Sets and Arrays.
Question 1
Firstly I'm interested in why they all use a different method to add items to it.
Set.add("item");
Map.set("item");
Array.push("item");
is there method to the madness rather than keeping them all as .push
?
Question 2
size vs length.
Why have Map and Set got .size
but Array has .length
why not use the same?
Question 3
When would you use Map over Array? can anybody give a real world example for this, I understand you can do things like use objects as keys in Maps, but why would you do that in the first place.
Hopefully somebody can clear this up to help inform other new starters to ES2015, thanks.