Nitin Agarwal Nitin Agarwal - 7 days ago 8
Javascript Question

Javascript ES6 Difference between ()=>() and ()=>{}

I have seen a code something like while learning React

const LinkCell = ({rowIndex, data, col, ...props}) => (
<Cell {...props}>
<a href="#">{data.getObjectAt(rowIndex)[col]}</a>
</Cell>
);


Also, so far I thought that in ES6 function shorthand is

let sum = (a, b)=>{
return a + b;
}


How the first one is different from the second one ?

Answer

with the ()=> () syntax imagine if there was an implicit return statment e.g. () => {return ()}

Comments