I'm really digging this double arrow syntax right now

  • 2
    ES6 is great. Makes code so much cleaner and easier to write :D
  • 1
    Correct me if I'm wrong, but
    Hey is a function (name) that exists of an anonymous function(activity)?
  • 3
    Hey is a function that accepts name and returns a function that accepts activity.

    hey = function(name) {
    return function(activity){}
  • 1
    @ImJosh Look at functions as objects.
    heyJosh = hey("Josh")

    heyJosh is now a function(activity)
  • 1
    @incognito @ImJosh sorry, I use them inside a React.component so I don’t put const in front of variables.
    This is same as function(name){ return function(activity){ ... }}. If you interested, type it in and take a look at Babel transform result.
    Why is it useful?
    <button onClick={this.onClick(param)} />
    So I can pass some parameters into onClick event, and still receive event
  • 1
    @A4Abhiraj you are right!👍
  • 1
    // My favourite line of code ever
  • 3
    @ImJosh It's called currying.
  • 1
    @Root immediately thought currying when I saw the screenshot!
Add Comment