-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
490 lines (302 loc) Β· 10.1 KB
/
index.js
File metadata and controls
490 lines (302 loc) Β· 10.1 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
// console.log('hello world');
//values and variables
// var myName="vinod bahadur thapa";
// console.log(myName);
//Data type in javascript
// 1 : "undefined"
// 2 : "boolean"
// 3 : "number"
// 4 : "string"
// 5 : "bigint"
// 6 : "symbol"
// console.log(10+"20");
// console.log(9-"4");//bug
// console.log("Java "+"Script");
// console.log("Java "-"Script"); // NaN
// var iAmUseLess=null;
// console.log(iAmUseLess);
// console.log(typeof(iAmUseLess));//bug
// var number=9761268926;
// var name='yash';
// console.log(isNaN(name));
// console.log(isNaN(number));
//expression and operator
// var x=10;
// var y=10;
// console.log("is x and y are equal or not "+ x==y);
//both have different output
// console.log( x==y);
//Important
// var num=15;
// // var newNum=num++ + 5; // (num + 5)
// var important= ++num + 5;
// console.log(important);
// // console.log(newNum);
// console.log(!false);
//string concatenation (operations)
// console.log("hello "+"world "+"yash varshney");
//exponentiation operator
// console.log(3**3);
// console.log(10**-1);
// console.log(10+" yash varshney");
//swap to number
// var a=10;
// var b=5;
// var temp=b;
// b=a;
// a=temp;
// a=a+b;
// b=a-b;
// a=a-b;
// console.log(a);
// console.log(b);
//difference betwwen == and ===
// var num1=5;
// var num2='5';
// console.log(num1==num2);
// console.log();
// console.log(num1===num2);
//truly and falsy value in javascript ~
//in javascript there are total 5 falsy values
// 0,"",undefined,null,NaN,false
// if(NaN){
// console.log("yash varshney");
// }else
// {
// console.log("akshat varshney");
// }
//function in javascript
//A javascript function is a block of code designed to perform a particular task.
// function sum( a,b){ // a and b are arguments
// var total=a+b;
// return total;
// }
// console.log(sum(10,30)); //10 and 40 are parameter
//Anonymous Functions are the functions which have no name
// var funE=function(a,b){
// return a+b;
// }
// console.log(funE(5,15));
// WELCOME TO ECMAScript
//ECS6 Updated on 2015
//1- LET AND CONST
//2- TEMPLATES STRINGS
//3- DEFAULT ARGUMENTS
//4- REST OPERATORS
//5- DESTRUCTURINGS
//6- OBJECT PROPERTIES
//7- ARROW FUNCTIONS
//8- SPREAD OPERATORS
//Now its time to moderm javascript
// var --> function scope
// let and const are --> Block Scope
// the measure differnce bettween let and var are scope var is function scope and let is block scope.
//templates literals
// for(let num=1;num<=10;num++){
// let tableof=12;
// console.log(`${tableof}*${num}=${tableof*num}`);
// }
//Default Parameters
// function mult(a=7,b=5){
// return a*b;
// }
// console.log(mult(5));
//fat arror functions
// const sum=(a,b) => `the sum of the two number is ${(a)+(b)} `;
// console.log(sum(50,90));
// array in javascript
// let a=['yash','varshney','akshat','ram','prashant'];
// console.log(a.length);
//for in loop
// let a=['yash','varshney','akshat','ram','prashant'];
// for(let Element in a ){
// console.log(Element);
// }
//for of loop
// for(let Element of a ){
// console.log(Element);
// }
// for each loop
// let a=['yash','varshney','akshat','ram','prashant'];
// a.forEach((element,index,array) =>{
// console.log(element+"index :"+index +" "+array);
// });
//Searching and filter in am array
//index of π’
// let data=["vinod","bahadur","thapa","thapatechnical","thapa"];
// console.log(data.indexOf("thapa",3));
//Last Index of π’
// let data=["vinod","bahadur","thapa","thapatechnical","thapa"];
// console.log(data.lastIndexOf("thapa"));
//includes π’
// let data=["vinod","bahadur","thapa","thapatechnical","thapa"];
// console.log(data.includes("thapa"));
//filtration in javascript π’
// const prices = [200, 300, 350, 400, 500, 600];
// //price<400
// const findElem = prices.find((currentValue) => currentValue < 400);
// console.log(findElem);
// const prices = [200, 300, 350, 400, 500, 600];
// //price<400
// const findElem = prices.findIndex((currentValue) => currentValue < 400);
// console.log(findElem);
//filter in javascript π’
// const prices = [200, 300, 350, 400, 500, 600];
// //price<400
// const findElem = prices.filter((currentValue) => currentValue < 400);
// console.log(findElem);
//sort in javascript π’
// const month=['march','jan','feb','dec','nov'];
// console.log(month.sort());
// const prices = [1,30,4,21,100000,99];
// console.log(prices.sort());
//perfrom CRUD π’
//push π
// const animals=['pigs','goats','sheep'];
// const count=animals.push('chicken');
// console.log(animals);
// console.log(count);
//unshift π
// const animals=['pigs','goats','sheep'];
// const count=animals.unshift('chicken' ,'cow','dogs');
// console.log(animals);
// console.log(count);
//pop π©
// const animals=['pigs','goats','sheep'];
// const count=animals.pop();
// console.log(animals);
// console.log(count);
//splice π
// const month=['march','jan','feb','dec','nov'];
// // const newmonth=month.splice(4,0,"yash");
// // const update=month.splice(5,5,"varshney");
// const update=month.splice(4,1);
// console.log(update);
// console.log(month);
//Map method in javascript π
// const array1=[1,4,9,16,25];
// let newArray=array1.map((currentValue,index,arr)=>
// currentValue>9
// );
// console.log(newArray);
// const array1=[1,4,9,16,25];
// let newArray=array1.map((currentValue,index,arr)=>
// `index no = ${index} and the value is ${currentValue} belong to ${arr}`
// );
// console.log(newArray);
// Find the square root of each element
// let arr=[25,36,49,64,81];
// let arrSqr=arr.map((currentValue)=>
// Math.sqrt(currentValue)
// );
// console.log(arrSqr);
// let arr1 = [2, 3, 4, 6, 8];
// let arrGre = arr1.map((currentValue) => currentValue * 2
// ).filter((currentValue) => currentValue > 10).reduce((accumulator,currentValue)=>accumulator+currentValue);
// console.log(arrGre);
//Reduce Method π’
// It is uase to flattern the 2d and 3d array into 1d array
// let arr=[5,6,2];
// let sum=arr.reduce((accumulator,curElem,index,arr)=>{
// return accumulator+curElem;
// });
// console.log(sum);
// π String in javascript
// Escape Character
// Finding a String in a String
// searching for a String in a String
// Extracting String Parts
// Replacing String content
// Extracting string Character
// Other useful methods of String
// let myName="yash varshney";
// console.log(myName.length);
// π± Escape Character
// let any1 ="my name is \"yash varshney\" ";
// console.log(any1);
// let any ='my name is "yash varshney" ';
// console.log(any);
// π±Finding String in String
// const name="i am yash varshney";
// console.log(name.indexOf("yash"));
//Extracting String parts π’
//Slice method in string
// slice() extract a part of a string and returns the extracted part to the new string
//methods takes two parameters the start position and the end position the start parameter is include but end parmeter is not include.
// let str="Apple, banana, kiwi";
// let res=str.slice(0,5);
// let count=str.slice(7,-2);
// console.log(res + count);
// π’ Display only 280 charcter of a string like the one used in twitter
// let myTweets= "wndjwduhewhfgewufguhrfheurhfu3hfuhqwufhwbgfhbwhjdfbhjsbdfhgbvhgfbvhdsbbadsnhfhgdsvfhvsdshfbhdsbfhgbwhgfvhvwfhvsahdf ghds cv scb cb cna chdbcvhhbvjbejfbjhewfueuhfhuqeya sh varshney bSGYUGQS Rhuahsipepsomajhhdhwjdhbhwjd bdcbwdcbbhjhhuehfuhefuheufeu yahhgdwjwheb wbdhwegudgeuwhu yash varshney pepsi is a good coedr the hchudh cosechef jsdhwhdheufhiuehfhuf bweuhuhewuihfue bwhehweihyfuiehufhjhbfjhsbdc hbduhggeqfuyerfiuygerf eurfihgfrgerygfyuerfyugeyfgywegfyewgfyugewyfgyewgfygewygfyuewgfyuewfgjcbnsbdcvnbcvmzxnbchjdsgjgwefyuewiruweytroiuwrqwewertyuiiooppnjjjaiiaiaooaoaoaoajjjjhjqwertyyuiioopplkkjjhhggffddssaazzxxccvvbbnnnmm,,,ll;;[]lsapxoksoijxoadcujhduvhuhdbnusuhurhgiuhrtghtrhgihreighiergiwerigitrgutrgiuoetr";
// let myactualtweets=myTweets.slice(0,280);
// console.log(myactualtweets);
// console.log(myactualtweets.length);
//substring method π’
// let str="Apple, banana, kiwi";
// let res= str.substring(0,4);
// console.log(res);
//substr π’
// let str="Apple, banana, kiwi";
// let res= str.substr(-4);
// console.log(res);
//Replacing string content() π
// let myname="i am yash varshney";
// let res=myname.replace("yash", "akshat");
// console.log(res);
// console.log(myname);
// Extracting String Characters π
//CharAt π’
// let str="HELLO WORLD";
// console.log(str.charAt(0));
//CharCodeAt π’
// let str="HELLO WORLD";
// console.log(str.charCodeAt(0));
// trim method π
// let str=" HELLO WORLD ";
// console.log(str.trim());
//converting a string into array π
// let txt="a,b,c,d,e,f";
// console.log(txt.split(","));
// console.log(txt.split(" "));
//
//
//Date and time in javascript π’
//Javascript Date objects represent a single moment in time in a platform-independent format. Date objects contains a number that rpresents milliseconds since 1 January 1970 UTC.
// Date objects are created with the new Date() constructor.
// let currDate=new Date();
// console.log(currDate.toString());
// console.log(currDate.toLocaleString());
// π
Date now give the millisecond in return
// console.log(Date.now());
// let Date_cur=new Date(2022,7,9,18,27,26,0);
// console.log(Date_cur.toLocaleString());
//Date Method π
// let d=new Date();
// console.log(d.toLocaleString());
// console.log(d.getFullYear());
// console.log(d.getMonth());
// console.log(d.getDate());
// console.log(d.getDay());
// Time method β²οΈ
// let d=new Date();
// console.log(d.getTime());
// console.log(d.getHours());
// console.log(d.getMinutes());
// console.log(d.getSeconds());
// console.log(d.getMilliseconds());
// πMaths Objects
// console.log(Math.PI);
// let num=10.265;
// console.log(Math.round(num));
// console.log(Math.trunc(-99.5));
// console.log(Math.ceil(-99.5));
// console.log(Math.floor(-99.1));
// Events π
// Section 4 ways of writing events in javscript
// input events π
// Timing Based events in javascript β²οΈ
//1οΈβ£ setTImeout()
//2οΈβ£ setInterval()
//3οΈβ£ clearInterval()
//4οΈβ£ clearInterval()