Polyfill Javascript
- A polyfill is a piece of code that provides the functionality of a modern feature in older browsers that do not support it natively.
- It essentially "fills in the gaps" in browser compatibility, allowing you to use newer features without worrying about whether the user's browser supports them.
Example
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, thisArg) {
for (let i = 0 ; i < this.length ; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}