Actually I am dealing with the problem to let my code work in IE. Unfortunately this is still necessary.
Polyfills for unsupported methods are working fine. But I wonder, how / if I can make "const" and "let" work. Is there any way to do that?
Same question about arrow-functions which may be much harder.
Best regards, Christian
You can't polyfill syntax changes to the language. But you can transpile your code that uses new syntax into code that uses older syntax, using tools like Babel or Traceur, and then run that generated older-style code on IE. They compile (or "transpile") code written with, say, ES2015+ features into code written with only ES5-level features (usually combined with polyfills).
For example, this code using an arrow function:
Nifty.prototype.setupHandler = function() {
this.element.addEventHandler("click", e => {
++this.clicks;
});
};
is transpiled by Babel into:
Nifty.prototype.setupHandler = function () {
var _this = this;
this.element.addEventHandler("click", function (e) {
++_this.clicks;
});
};