Anybody using ES6 yet?

General Discussion
  • As a non-developer. What the heck is ES6, and why is it made of node.js magic?

  • ECMAScript 2015 (ES6) in Node.js

  • function (player) {
      var strength = player.strength,
          agility  = player.agility,
          wisdom   = player.wisdom;
    }
    

    I so want this... πŸ˜›

    player => {
      var {strength, agility, wisdom} = player;
    }
    
  • @yariplus Hahaha, the main thing I am worried about is that it looks like Greek to me! (no offence to Greeks on this board πŸ˜‰ )

    Perhaps with time that syntax will become easier to parse, but right now (as with a bunch of other ES6 examples), my brain fuzzes out and I have no mental modal of what the output is supposed to look like.

    e.g. var f = (i) => arguments[0]+i;

    ☝ wat. πŸ˜†

    @frissdiegurke I am also excited for the eventual deprecation (or should I say "eventual falling-out-of-favour") of var in favour of let. Bring it on!

    There's .startsWith() and .endsWith() in ES6? Funny, we already use those in NodeBB πŸ˜›

  • I've been using promises for a long time. Mostly bluebird and native when possible. Such a relief and makes code readable again!

    @julian, you won't miss the callback hell. Promise. πŸ™‚

  • I've been using ES6 for few months already in our project because we have an ES6 to ES5 transpiler (Babel). There is an unwritten rule now in the team to only use let and const. The var thing never happened πŸ˜…

    At the beginning I thought arrow functions were super ugly, but now that I got used to them is fine. You can even omit parenthesis, curly brackets and return keyword quite frequently. But I think the best part of arrow function is that it implicitly binds this object so there is no need to specify function() { }.bind(this) anymore.

    Anyway, my favorite one is template strings. We make custom elements so we usually need a lot of strings with variables. This feature is super handy πŸ™‚

    If I'm not wrong async/await is actually for ES7, right?

  • @hek said:

    @julian, you won't miss the callback hell. Promise. πŸ™‚

    I see what you did there πŸ‘€

    But I like callbacks... async has made it a non-issue. Not clear how much of that is the stockholm syndrome talking...

  • @yariplus your syntax is wrong, should be curly braces, not square brackets. Square brackets are for arrays.

    @julian been using ES6 in my newest project with webpack and Babel, you get used to it really fast. Also, async and await are not ES6 features.

    Anyways, Julian, I think NodeBB should adopt the Airbnb style guide with ESlint. It's an amazing guide.

  • @FDX said:

    If I'm not wrong async/await is actually for ES7, right?

    @PitaJ said:

    Also, async and await are not ES6 features.

    Alright, I get it, I didn't do my research before making this topic πŸ˜†

  • Just using function syntactic sugar var hello = (name) => {....} πŸ˜„

    And this makes code clear in async flow

    async.waterfall([
      (next) => {
        next(err, 'name')
      },
      (name, next) => {
        next(err, 'final')
      }
    ], callback)
    


Suggested Topics