forked from thenaveensaggam/JavaScript_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path26_Script.js
More file actions
44 lines (35 loc) · 1.68 KB
/
26_Script.js
File metadata and controls
44 lines (35 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ES6 Collections */
/*
---------------------------------------------------------------------------------
Map Collection in ECMAScript
---------------------------------------------------------------------------------
*/
/*
Map is a collection of keyed data items,just like an Object.
But the main difference is that Map allows keys of any type.
new Map() – creates the map.
map.set(key, value) – stores the value by the key.
map.get(key) – returns the value by the key, undefined if key doesn’t exist in map.
map.has(key) – returns true if the key exists, false otherwise.
map.delete(key) – removes the value by the key.
map.clear() – clears the map
map.size – returns the current element count.
map.keys() – returns the keys for iteration,
map.values() – returns the values for iteration,
map.entries() – returns the entries [key, value], it’s used by default in for..of.
*/
/*
---------------------------------------------------------------------------------
Set Collection in ECMAScript
---------------------------------------------------------------------------------
*/
/*
A Set is a collection of values, where each value may occur only once.
Set contains the following methods
new Set(iterable) – creates the set, optionally from an array of values (any iterable will do).
set.add(value) – adds a value, returns the set itself.
set.delete(value) – removes the value, returns true if value existed at the moment of the call, otherwise false.
set.has(value) – returns true if the value exists in the set, otherwise false.
set.clear() – removes everything from the set.
set.size – is the elements count.
*/