I've been trying to learn some of the new features of ES6, and while most of it makes sense, I'm having trouble grasping the arrow function. I'm not asking so much why it exists as I am how to read it.
Previously in JS, when a function was defined, the syntax reads really nicely.
var foo = function(property) { return property + 'bar' }
says: define a variable 'foo' that is a function that returns property + 'bar'.
Alternatively, function foo(property) {}
roughly reads as: define a function named foo that has a property.
But when I see something with an arrow function:
const foo = (property) => { return property + 'bar' }
How do I read that? Define a constant 'foo' that equals...a property...that equals...returning a property plus 'bar'?
Then, probably because I don't fully understand this concept, I get to a line like this and get pretty lost:
const actionLogger = ({dispatch, getState}) => (next) => (action) => {
console.log(action); return next (action)
}
In a Redux instructional video, the author switches to arrow functions because it 'has clearer semantics in ES6', so I just want to understand the semantics of arrow functions!
property
toproperty + 'bar'
". I've seen this kind of phrasing elsewhere.