-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex19.js
74 lines (64 loc) · 1.4 KB
/
index19.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//set and maps
//functional programming
//strings
//set
let a = new Set();//set declaration
let set =new Set();
set.add(5);
console.log(set);//Set(1) { 5 }
set.add("Maithaly");
set.add("maithaly");
console.log(set);//Set(2) { 5, 'maithaly' }
console.log(set.size);//2
set.delete("maithaly");
console.log(set);
//Map
let map =new Map();
map.set("Navin","Java");
map.set("Hyder","JS");
map.set("sanjeevan","blockchain");
map.set("maithaly","Edge Coumputing");
map.set("maithaly","Blockchain");
console.log(map);/*Map(4) {
'Navin' => 'Java',
'Hyder' => 'JS',
'sanjeevan' => 'blockchain',
'maithaly' => 'Blockchain'
}
*/
console.log(map.keys());/*[Map Iterator] { 'Navin', 'Hyder', 'sanjeevan', 'maithaly' }*/
console.log(map.values());/*[Map Iterator] { 'Java', 'JS', 'blockchain', 'Blockchain' }*/
map.forEach((v,k)=>console.log(v));/* Java
JS
blockchain
Blockchain
*/
let values = [3,4,5,6,8];
values.forEach((v,i,values)=>console.log(v,i));/*
3 0
4 1
5 2
6 3
8 4
*/
//functional programming
setTimeout(function print(){
console.log("get lost");
},10000)//get lost after 10 sec.
function x(){
function y(){
console.log("in y");
}
console.log("in x");
y();
}
x();
function outer(){
console.log("outer");
return function(){
console.log("inner");/* outer
inner */
};
}
let result = outer();
result();