Skip to content

Comment on Xto6 modernizes your JavaScript codeparent

Comments

If you don't mind setting the function on instances at construct time, you can use ES2016 class properties:

    class x {
      a = wrapFunction(function() {})
    }
This kind of use case is pretty well covered by ES2016 decorators as well (they're a bit more general as they act on property descriptors, not just values):
    class x {
      @functionWrapper
      a() {}
    }

Neat, thanks! But we're working with the half-baked V8 ES6 support that is far from ES2016, unfortunately. However, it's interesting to see the support coming :-)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.