4
The functionality of Template String and Arrow Function are excellent to facilitate some Javascript operations. However, it seems that not all browsers still support the same.
In many cases of lack of support for new functions, such as Object.assign
, it is possible to make a Polyfill.
But in the case of Template String and Arrow Function? It would be possible to do some Polyfill?
I wonder this because it is related to Language Syntax.
Would there be some way to use these two excellent features in browser versions that do not yet have support?
You could use Babel: <https://babeljs.io/setup> It will convert your code that contains Arrow functions and template strings to code that supports older browsers. I don’t think it is possible to use a polyfill because you would have a syntax error. Babel will compile your code so it will make the necessary syntax transformations.
– Adriano Dantas
When the question is interpreter, there is no way to insert a function for such (case of Shim/polyfill), in this case only transpillators.
– Gabriel Heming
@Gabrielheming, that’s the doubt I was in. I heard comments that had Polyfill for this in Javascript, but the person may have confused Polyfill with transpilation.
– Wallace Maxters
Unless there is a way for Javascript to parse Javascript itself to transform into another valid Javascript :D
– Wallace Maxters
@Wallacemaxters There is, and that’s what Babel does. It’s even possible to do it in Runtime, but not recommended for obvious reasons.
– bfavaretto