Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm confused by this example:

    export default Component.extend({
      keyUp(event) {
        if (event.which === 13) {
          this.attrs['on-enter'](this.$().val());
        }
      }
   });
This is invalid ES5. I assume this is new ES6 module syntax, specifically the `keyUp(event) {`?



Having been rewriting a large system that was a disgusting jquery mishmash of terrible code in React/Flummox, all in ES6/ES7 classes and compiled down with Browserify, I'd never want to write JavaScript any other way. ES6 syntax like what you've pointed out is simply brilliant in everyday usage :)


yeah, it's ES6 shorthand for `keyUp: function (event) {`; the new syntax is valid both in objects and class definitions.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: