Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c47fb85 commit a58bd77Copy full SHA for a58bd77
fundamentals/oop_classes.md
@@ -107,4 +107,29 @@ const months = [
107
108
const longMonths = months.filter(month => month.isLongMonth());
109
longMonths.forEach(month => console.log(month.toString()));
110
+```
111
+
112
+### Bonus: Array.prototype.map & Array.prototype.filter implementations
113
114
+```js
115
+Array.prototype.myMap = function (mapFn) {
116
+ const arr = [];
117
+ for (let i = 0; i < this.length; i++) {
118
+ arr.push(mapFn(this[i], i, this));
119
+ }
120
+ return arr;
121
+};
122
123
124
125
126
+Array.prototype.myFilter = function (predicateFn) {
127
128
129
+ if (predicateFn(this[i], i, this)) {
130
+ arr.push(this[i]);
131
132
133
134
135
```
0 commit comments