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
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
Share Improve this question asked Feb 5, 2018 at 13:19 Christian HeischChristian Heisch 2451 gold badge3 silver badges10 bronze badges 3- 3 I don't think you can create polyfil for keywords or reserved words. – gurvinder372 Commented Feb 5, 2018 at 13:20
- 1 You may find it better to transpile your code, if possible. – Federico klez Culloca Commented Feb 5, 2018 at 13:21
- 1 No, if you have to support IE, than you need to use something like babel in your build process. – epascarello Commented Feb 5, 2018 at 13:22
1 Answer
Reset to default 6You 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 pile (or "transpile") code written with, say, ES2015+ features into code written with only ES5-level features (usually bined 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;
});
};
Example
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745268067a4619578.html
评论列表(0条)