--

Is it necessary to use `.call` for filter and reduce. Can I just normally call the predicate with the array element ? like

Array.prototype.myfilter = function (func) {

let arr = this;

let newArr = [];

for (let i = 0; i < arr.length; i++) {

if (func(arr[i])) {

newArr.push(arr[i]);

}

}

return newArr;

};

--

--

Santosh Viswanatham
Santosh Viswanatham

Written by Santosh Viswanatham

Javascript Engineer | Product Developer | Tech Speaker | Angular | React | WebVR | Browser Add-ons

Responses (1)