-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrevision.txt
71 lines (41 loc) · 1.73 KB
/
revision.txt
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
1. higher order function
-filter:take array and return the new array which meets the given condition
array.filter(callback(element) => condition);
-map: take array and return the new array and apply the transformation to the each element
array.map(callback(element) => transformation);
-some:returns the true or false based on the condition if at least one element in the array passes the condition
array.some(callback(element) => condition);
-every:returns the true or false based on the condition if all the elements in the array passes the condition
array.every(callback(element) => condition);
-reduce:its like a loop in array, it reduces the value to a single value
array.reduce((accumulator, element) => operation, initialValue);
2.String methods:
-concat:string1.concat(string2, ...);
-charAt:string.charAt(index);
-toLowerCase:string.toLowerCase();
-toUpperCase:string.toUpperCase();
-trim:string.trim();
-slice:string.slice(startIndex, endIndex);
-substring:string.substring(startIndex, endIndex);
-indexOf:string.indexOf(substring);
-includes:string.includes(substring);
-replace:string.replace(substring, newSubstring);
-replaceAll:string.replaceAll(substring, newSubstring);
3.object methods:
-Object.keys:
-Object.values:
-Object.entries:
4.cloning:
-Object.assign:Object.assign({}, sourceObject);
-spread method:const newObject = { ...sourceObject };
-JSON.parse and JSON.stringify:const deepClone = JSON.parse(JSON.stringify(sourceObject));
5.object function:
-factory function:
-constructor function:
6.array methods:
-sort:array.sort((a, b) => a - b); // ascending
-reverse:array.reverse();
-push:array.push(element1, element2, ...);
-pop:array.pop();
-shift:array.shift();
-unshift:array.unshift(element1, element2, ...);