What is Polyfill in JS?
​
Today I got to know about polyfill by using this we can add and modify a function in javascript.
Like we can built custom map function
Array.prototype.myMap = function (callback){
const res = [];
for(let i=0;i<this.length;i++){
res.push(callback(this[i]))
}
return res;
}
const arr = [1,2,3,4]
const newArr=arr.myMap((ele)=>ele*2)
console.log(newArr)
u/Own_Grand1767 — 19 hours ago