-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods.html
More file actions
403 lines (370 loc) · 11.2 KB
/
methods.html
File metadata and controls
403 lines (370 loc) · 11.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Object, Array, String: Methods</title>
<style>
body {
margin: 0;
min-height: 100vh;
display: flex;
background-color: #998;
color: #333;
}
main {
max-width: 60rem;
margin-left: auto;
margin-right: auto;
border: 5px dashed #cc4;
padding: 1rem;
}
dl {
background-color: #aeae9e;
border: 2px dotted #666;
border-radius: 10px;
padding: 1rem;
}
dt {
font-weight: bold;
}
</style>
</head>
<body>
<main>
<h1>Object, Array, String: Methods</h1>
<ul>
<li><a href="/">back to my Github Page</a></li>
<li><a href="#object">Object methods</a></li>
<li><a href="#array">Array methods</a></li>
<li><a href="#string">String methods</a></li>
</ul>
<h3 id="object">Object methods</h3>
<dl>
<dt>delete()</dt>
<dd>
<ul>
<li>removes the property of an object</li>
<li>returns bolean</li>
</ul>
</dd>
<dt>assign()</dt>
<dd>
<ul>
<li>makes copy of values from one or more source objects to a target object</li>
<li>returns target object</li>
</ul>
</dd>
</dl>
<h3 id="array">Array methods</h3>
<h4>Array: search, select</h4>
<dl>
<dt>filter()</dt>
<dd>
<ul>
<li>finds all elements matching query; query can be a function returning bolean</li>
<li>makes new array from the result of callback function, if negative new array
is empty; does not change the original array</li>
</ul>
</dd>
<dt>map()</dt>
<dd>
<ul>
<li>calls a function for all elements of an array</li>
<li>makes new array from the result of callback function; does not change the original array</li>
</ul>
</dd>
<dt>includes()</dt>
<dd>
<ul>
<li>finds if searched element is in an array</li>
<li>returns bolean</li>
</ul>
</dd>
<dt>find()</dt>
<dd>
<ul>
<li>finds the first element matching query</li>
<li>returns it or undefined if not found</li>
</ul>
</dd>
<dt>findIndex()</dt>
<dd>
<ul>
<li>finds the first element matching query</li>
<li>returns its index or -1 if not found</li>
</ul>
</dd>
<dt>indexOf()</dt>
<dd>
<ul>
<li>finds if searched element is in an array</li>
<li>returns its index or -1 if not found</li>
</ul>
</dd>
<dt>lastIndexOf()</dt>
<dd>
<ul>
<li>the same as indexOf but starts from the end</li>
</ul>
</dd>
<dt>some()</dt>
<dd>
<ul>
<li>find if any element matches request</li>
<li>returns bolean</li>
</ul>
</dd>
<dt>every()</dt>
<dd>
<ul>
<li>find if every elements match request</li>
<li>returns bolean</li>
</ul>
</dd>
</dl>
<h4>Array: change</h4>
<dl>
<dt>join()</dt>
<dd>
<ul>
<li>joins the elements of an array into a string; argument is a separator</li>
<li>returns string</li>
</ul>
</dd>
<dt>reduce()</dt>
<dd>
<ul>
<li>reduces values of all array elements to a single value kept in accumulator</li>
<li>reducer function</li>
</ul>
</dd>
<dt>reduceRight()</dt>
<dd>
<ul>
<li>the same as reduce() but starts from the end</li>
</ul>
</dd>
<dt>reverse()</dt>
<dd>
<ul>
<li>reverses the order of all elements of an array</li>
</ul>
</dd>
<dt>sort()</dt>
<dd>
<ul>
<li>sorts the elements of an array</li>
<li>changes the original array</li>
</ul>
</dd>
</dl>
<h4>Array: add, remove</h4>
<dl>
<dt>shift()</dt>
<dd>
<ul>
<li>removes the first element of an array</li>
<li>returns it</li>
</ul>
</dd>
<dt>pop()</dt>
<dd>
<ul>
<li>removes the last element of an array</li>
<li>returns it</li>
</ul>
</dd>
<dt>unshift()</dt>
<dd>
<ul>
<li>adds a new element at the beginning</li>
<li>returns lenght of an array</li>
</ul>
</dd>
<dt>push()</dt>
<dd>
<ul>
<li>adds a new element at the end of an array</li>
<li>returns lenght of an array</li>
</ul>
</dd>
<dt>slice()</dt>
<dd>
<ul>
<li>selects a part of an array specified by beginning and end of splice or all array if end is not specified</li>
<li>returns the new array</li>
<li>does not change the original array; both parameters are optional: start (from where to select), and end
(index where to stop; index element is not taken), defaults are zero and the end</li>
</ul>
</dd>
<dt>splice()</dt>
<dd>
<ul>
<li>adds/removes elements from an array specified by beginning and end of splice, if beginning is negative it
operates at the end of an array; end is specified by number of elements to delete, if 0 it just place new
element into an array</li>
<li>returns removed elements</li>
<li>changes the original array; index (from what point to change) is obligatory, end (how many elements to
delete) and elements are optional</li>
</ul>
</dd>
</dl>
<h3 id="string">String methods</h3>
<dl>
<dt>charAt()</dt>
<dd>
<ul>
<li>finds the character at the specified index (starts with 0, -1 is the last one) in a string</li>
<li>returns it</li>
</ul>
</dd>
<dt>concat()</dt>
<dd>
<ul>
<li>joins two or more strings, those after first are passed as an arguments; does ot change them</li>
<li>returns new concatenated string</li>
</ul>
</dd>
<dt>includes()</dt>
<dd>
<ul>
<li>checks if the calling string contains a string passed as an argument; case sensitive</li>
<li>returns bolean</li>
</ul>
</dd>
<dt>endsWith()</dt>
<dd>
<ul>
<li>checks if the calling string ends with a string passed as an argument; case sensitive</li>
<li>returns bolean</li>
</ul>
</dd>
<dt>indexOf()</dt>
<dd>
<ul>
<li>finds first ocurence of a specified argument; optional second argument is an integer specifying index of
place where to start searching; case sensitive</li>
<li>returns index, or -1 if not found</li>
</ul>
</dd>
<dt>lastIndexOf()</dt>
<dd>
<ul>
<li>the same as indexOf(), but backwards</li>
</ul>
</dd>
<dt>match()</dt>
<dd>
<ul>
<li>searches a string for a match against a regular expression; without g modifier (global) it finds only the
first one</li>
<li>returns the matches (as substring), index, and the input, all as an Array object, or null if not found</li>
</ul>
</dd>
<dt>repeat()</dt>
<dd>
<ul>
<li>finds an element at index given as an argument</li>
<li>returns a string of that element repeated number of times (this number is a second argument), or empty
string if no argument or argument 0</li>
</ul>
</dd>
<dt>replace()</dt>
<dd>
<ul>
<li>finds a match between a regular expression (or a specified value) and a string; does not change the
original string; without g modifier (global) it replaces only the first occurence</li>
<li>returns a new string where the specified values are replaced, or the original string if no match is found</li>
</ul> .
</dd>
<dt>search()</dt>
<dd>
<ul>
<li>searches for a match between a string or regular expression and a specified string</li>
<li>returns the index of the first character of the first match, or -1 if no match is found</li>
</ul>
</dd>
<dt>slice()</dt>
<dd>
<ul>
<li>extracts a section of a string, from the index specified in the first argument, to index specified by the
second argument (i, j-1), or end of string if there's no second argument; negative numbers are extracting
from the end</li>
<li>returns result, or the entire string if no arguments are passed, as a new string</li>
</ul>
</dd>
<dt>split()</dt>
<dd>
<ul>
<li>splits a string into an array of strings by separating the string into substrings, argument is the
separator; does not change the original string</li>
<li>returns an array of substrings, or the entire array of string's elements if no argument or empty argument
('') are passed</li>
</ul>
</dd>
<dt>startsWith()</dt>
<dd>
<ul>
<li>checks if a string begins with a string passed as an argument; case sensitive</li>
<li>returns bolean</li>
</ul>
</dd>
<dt>substr()</dt>
<dd>
<ul>
<li>extracts strings of number of characters specified in the second argument from index specified in the
first argument; negative number extracts from the end of a string; does not change the original string</li>
<li>returns a substring of elements at a given range</li>
</ul>
</dd>
<dt>substring()</dt>
<dd>
<ul>
<li>extracts strings form index specified in the first argument to index specified in the second argument;
does not change the original string</li>
<li>returns a substring of elements at a given range</li>
</ul>
</dd>
<dt>toLowerCase()</dt>
<dd>
<ul>
<li>does not change the original string</li>
<li>returns the calling string converted to lowercase letters</li>
</ul>
</dd>
<dt>toUpperCase()</dt>
<dd>
<ul>
<li>does not change the original string</li>
<li>returns the calling string converted to uppercase letters</li>
</ul>
</dd>
<dt>trim()</dt>
<dd>
<ul>
<li>removing whitespaces from both ends of string; does not change the original string</li>
<li>returns changed string</li>
</ul>
</dd>
<dt>trimLeft()</dt>
<dd>
<ul>
<li>removing whitespace from the left side</li>
<li>returns changed string</li>
</ul>
</dd>
<dt>trimRight()</dt>
<dd>
<ul>
<li>removing whitespace from the right side</li>
<li>returns changed string</li>
</ul>
</dd>
</dl>
</dl>
<p><a href="#">back to the top of page</a></p>
</main>
</body>
</html>