Hacker News new | ask | show | jobs
by secoif 4181 days ago
Also removes return statement for 1 liners. Reduces clutter of anon functions, especially when you're chaining a bunch together

e.g.

ES5

    users.map(function(user) {
      return user.name
    }).filter(function(name) {
      return name.length < 30
    }).sort(function(a, b) {
      return a.length - b.length
    })
vs

ES6

    users
    .map(user => user.name)
    .filter(name => name.length < 30)
    .sort((a, b) => a.length - b.length)
Contrived, but typical example.