-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst-app.js
More file actions
163 lines (103 loc) · 2.07 KB
/
first-app.js
File metadata and controls
163 lines (103 loc) · 2.07 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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const fs=require('fs');
fs.writeFileSync('hello.txt','Hello from Node.js');
console.log('hello world');
const prod= (a,b) => {
return a*b;
}
console.log(prod(5,2));
const student={
name:'Mohit',
age:24
}
console.log(student.name);
const arr=['apple','orange','mango','lemon'];
console.log(arr);
console.log(arr.map((fruit)=>{
return 'fruit: '+fruit;
}));
//spread operator
const copiedArray=[...arr];
console.log(copiedArray);
//rest operator- it will bundle all the arguments in an array
const toArray=(...args) => {
return args;
};
console.log(toArray(1,2,3,4));
/*
const obj1 = {'key1': 1}
const obj2 = { ...obj1}
if(obj2 === obj1){
console.log('same objects')
}
else{
console.log('different objects')
}
*/
/*
const obj1 = {'key1': 1 , 'key2' : 2}
const obj2 = { ...obj1, key1: 1000}
console.log(obj1)
console.log(obj2)
*/
const printName=({name}) => {
console.log(name);
}
printName(student);
const {name,age} =student;
console.log(name,age);
const [fruit1,fruit2]=arr;
console.log(fruit1,fruit2);
/*
const obj1 = {'key1': 1, "key2": 2, "key3": 1000}
const { key1, key3} = { ...obj1}
console.log(key1, key3)
*/
/*
const arr1 = ['value1', 'value2']
const [ val1, val2 ] = arr1
console.log(val1)
console.log(val2)
*/
/*
const obj1 = {'key1': 1, "key2": 2, "key3": 1000}
let { key1, key3} = obj1
//key1 = 20;
//key3 = 123;
console.log(key1);
console.log(obj1.key1, obj1.key3)
*/
/*
console.log('a');
console.log('b');
setTimeout(() => console.log('c'), 3000)
console.log('d');
*/
/*
console.log('a');
console.log('b');
setTimeout(() => console.log('c'), 3000)
setTimeout(() => console.log('d'), 0)
console.log('e');
*/
/*
const abcde= async () => {
console.log('a');
console.log('b');
const logc=new Promise((resolve,reject) => {
setTimeout(() => {
resolve('c');
}, 3000);
});
const logd=new Promise((resolve,reject) => {
setTimeout(() => {
resolve('d');
}, 0);
});
let printc= await logc;
console.log(printc);
let printd= await logd;
console.log(printd);
console.log('e');
}
abcde();
*/