How does callback fn work in JS & how can it be implemented?
Array.prototype.myFilter = function (callback) { const newArray = []; // Only change code below this line for (let i = 0; i < this.length; i++) { if (callback(this[i], i, this) == true) { newArray.push(this[i]); } } //This function works like…