- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.html
More file actions
Latest commit
157 lines (152 loc) · 7.43 KB
/
Copy pathAPI.html
File metadata and controls
157 lines (152 loc) · 7.43 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
<!DOCTYPE html>
<html>
<head>
<metahttp-equiv="Content-type" content="text/html;charset=UTF-8">
<title>ARRAY API</title>
<linkrel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
<linkrel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
<linkrel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
<linkhref="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css" rel="stylesheet" type="text/css">
<style>
.task-list-item { list-style-type: none; } .task-list-item-checkbox { margin-left:-20px; vertical-align: middle; }
</style>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont,'Segoe WPC','Segoe UI','HelveticaNeue-Light','Ubuntu','Droid Sans', sans-serif;
font-size:14px;
line-height:1.6;
}
</style>
<scriptsrc="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script>
</head>
<body>
<h2id="array-api">ARRAY API</h2>
<pre><codeclass="language-javascript"><div><spanclass="hljs-keyword">let</span> array = [<spanclass="hljs-number">0</span>,<spanclass="hljs-number">1</span>,<spanclass="hljs-number">2</span>,<spanclass="hljs-number">3</span>,<spanclass="hljs-number">4</span>,<spanclass="hljs-number">5</span>].slice(<spanclass="hljs-number">1</span>, <spanclass="hljs-number">5</span>) <spanclass="hljs-comment">// [1, 2, 3, 4] : get index from 1 to 4 </span>
<spanclass="hljs-keyword">let</span> array = [<spanclass="hljs-number">0</span>,<spanclass="hljs-number">1</span>,<spanclass="hljs-number">2</span>,<spanclass="hljs-number">3</span>,<spanclass="hljs-number">4</span>,<spanclass="hljs-number">5</span>]
array.splice(<spanclass="hljs-number">2</span>, <spanclass="hljs-number">0</span>, <spanclass="hljs-string">'toto'</span>) <spanclass="hljs-comment">// [0, 1, 'toto', 2, 3, 4] : insert 'toto' at the index 2</span>
array.splice(<spanclass="hljs-number">2</span>, <spanclass="hljs-number">0</span>, <spanclass="hljs-string">'toto'</span>, <spanclass="hljs-string">'tata'</span>) <spanclass="hljs-comment">// [0, 1, 'toto', 'tata', 2, 3, 4] : insert 'toto' at the index 2 (so push the previous on at index 3)</span>
array.splice(<spanclass="hljs-number">2</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment">// [0,1,4,5] delete two items starting at the index 2</span>
array.concat(array2) <spanclass="hljs-comment">// return a new array</span>
array.reduce(<spanclass="hljs-function">(<spanclass="hljs-params">accumulator, currentValue, index, array</span>) =></span> {}, <spanclass="hljs-number">0</span>)
array.find()
array.findIndex()
array.include()
<spanclass="hljs-function"><spanclass="hljs-keyword">function</span><spanclass="hljs-title">compare</span>(<spanclass="hljs-params">a, b</span>) </span>{
<spanclass="hljs-keyword">if</span> (a is less than b by some ordering criterion) {
<spanclass="hljs-keyword">return</span><spanclass="hljs-number">-1</span>;
}
<spanclass="hljs-keyword">if</span> (a is greater than b by the ordering criterion) {
<spanclass="hljs-keyword">return</span><spanclass="hljs-number">1</span>;
}
<spanclass="hljs-comment">// a must be equal to b</span>
<spanclass="hljs-keyword">return</span><spanclass="hljs-number">0</span>;
}
<spanclass="hljs-function"><spanclass="hljs-keyword">function</span><spanclass="hljs-title">compareNumbers</span>(<spanclass="hljs-params">a, b</span>) </span>{
<spanclass="hljs-keyword">return</span> a - b;
}
</div></code></pre>
<h2id="math-api">MATH API</h2>
<p>let upperLimit = Number.MAX_SAFE_INTEGER : 9007199254740991 <br>
let lowerLimit = Number.MIN_SAFE_INTEGER : -9007199254740991</p>
<p>32 bit max : 2**31 - 1 <br>
32 bit min : -2**31</p>
<p>let pi = Math.PI; <br>
let squareRoot = Math.sqrt(); <br>
let max = Math.max(...numbers);</p>
<h2id="string-api">STRING API</h2>
<p>ASCII table : Majuscule before minuscule</p>
<pre><codeclass="language-javascript"><div><spanclass="hljs-built_in">String</span>.fromCharCode() <spanclass="hljs-comment">// get the character from the char code position</span>
<spanclass="hljs-string">'a'</span>.charCodeAt(<spanclass="hljs-number">0</span>) <spanclass="hljs-comment">// get ghe ACII char code position</span>
<spanclass="hljs-keyword">let</span> char = (<spanclass="hljs-string">'a'</span>.charCodeAt(<spanclass="hljs-number">0</span>) + <spanclass="hljs-string">'E'</span>.charCodeAt(<spanclass="hljs-number">0</span>) - <spanclass="hljs-string">'A'</span>.charCodeAt(<spanclass="hljs-number">0</span>)) <spanclass="hljs-comment">// 101 ('e') : get the code of the lower case</span>
</div></code></pre>
<h2id="date-api">DATE API</h2>
<pre><codeclass="language-javascript"><div><spanclass="hljs-keyword">let</span> dateFromString = <spanclass="hljs-keyword">new</span><spanclass="hljs-built_in">Date</span>(<spanclass="hljs-string">'2017-2-10T00:00:00Z'</span>)
<spanclass="hljs-keyword">let</span> dateFromTimstamp = <spanclass="hljs-keyword">new</span><spanclass="hljs-built_in">Date</span>(<spanclass="hljs-number">1582217025</span>)
<spanclass="hljs-keyword">let</span> dateFromParams = <spanclass="hljs-keyword">new</span><spanclass="hljs-built_in">Date</span>(YEAR, MOUNT_START_AT_I_0, DAY, HOURS, MIN, SEC)
<spanclass="hljs-keyword">let</span> date = <spanclass="hljs-keyword">new</span><spanclass="hljs-built_in">Date</span>(...)
date.getTime() <spanclass="hljs-comment">// 1582217025</span>
date.toISOString() <spanclass="hljs-comment">// "2020-02-20T16:54:06.955Z"</span>
date.toString() <spanclass="hljs-comment">// "Thu Feb 20 2020 17:54:06 GMT+0100 (Central European Standard Time)"</span>
</div></code></pre>
<blockquote>
<p>Construct one for each date, then compare them using the >, <, <= or >=.</p>
<p>The ==, !=, ===, and !== operators require you to use date.getTime() as in</p>
</blockquote>
<h2id="system-design-and-scalability">SYSTEM DESIGN AND SCALABILITY</h2>
<p>read-heavy vs write-heavy <br>
failure <br>
availability vs reliability <br>
security \</p>
<p>Easy of use <br>
Easy to implement <br>
Flexible \</p>
<h2id="operators">OPERATORs</h2>
<table>
<thead>
<tr>
<th>Common operators</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Division assignment</td>
<td>x /= y</td>
<td>x = x / y</td>
</tr>
<tr>
<td>Remainder assignment</td>
<td>x %= y</td>
<td>x = x % y</td>
</tr>
<tr>
<td>Exponentiation assignment</td>
<td>x **= y</td>
<td>x = x ** y</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Bitwise operators</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Left shift assignment</td>
<td>x <<= y</td>
<td>x = x << y</td>
</tr>
<tr>
<td>Right shift assignment</td>
<td>x >>= y</td>
<td>x = x >> y</td>
</tr>
<tr>
<td>Unsigned right shift assignment</td>
<td>x >>>= y</td>
<td>x = x >>> y</td>
</tr>
<tr>
<td>Bitwise AND assignment</td>
<td>x &= y</td>
<td>x = x & y</td>
</tr>
<tr>
<td>Bitwise XOR assignment</td>
<td>x ^= y</td>
<td>x = x ^ y</td>
</tr>
<tr>
<td>Bitwise OR assignment</td>
<td>x |= y</td>
<td>x = x</td>
</tr>
</tbody>
</table>
</body>
</html>