Anybody using ES6 yet?


  • Admin

    I've been programming in ES5 so long it'll be quite a change to break my habits and move to ES6.

    What features of ES6 are you most excited about? Arrow functions? Promises? async/await?


  • Community Rep

    My favorite features so far are Destructuring, Arrow Functions, and all of the new String operations, especially templates.


  • GNU/Linux

    My favorites (in no specific order):

    • block scoped variables
    • String features, especially multi-line strings, startsWith, endsWith
    • computed property names
    • ... (function parameters and reducing array to its elements)
    • Promises

    I'm currently taking baby steps towards ES6 :D


  • Translator

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



  • ECMAScript 2015 (ES6) in Node.js


  • Community Rep

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

    I so want this... :p

    player => {
      var {strength, agility, wisdom} = player;
    }
    

  • Admin

    @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 😛


  • Plugin & Theme Dev

    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?


  • Admin

    @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...


  • Global Moderator

    @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.


  • Admin

    @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)
    

Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.