What’s a Polyfill?
A polyfill is the action of supplying a feature that the browser does not have therefore the browser uses that feature instead of throwing an exception. For example, the old version of IE doesn’t support the includes method, so you have to make your own implementation (Polyfill) or an error will be thrown.
How to implement polyfill in my code?
There are a lot of ways to use babel with webpack, install polyfill with npm or implement yourself. On this occasion, we go see implement polyfill yourself.
We guess that chrome no supports the method map that belongs to the prototype Array then we going to make a polyfill ourselves for the code to run properly.
It is a little fragment of code for this polyfill but map has much more features.
This code will be in the main application or index.js, here we can see if, here validate that function map was in the browser if not found then add the polyfill in the browser for that our code not broken.
In conclusion, the polyfill is very important to know since we can find ourselves in situations in which the browsers do not have a feature that we use in our code therefore we prevent an error.