I have a quick question, which I think related to line break or something, but I could not find an answer or post about. Here's an example using reduce() method.
This is what I usually do or see:
const unique = ['a','b','c','a''a','a','b'];
unique.reduce((acc, val)=> {acc[val]=(acc[val]||0)+1; return acc;}, {}); //{ a: 4, b: 2, c: 1 }
However, we can also use this syntax: remove the curly brackets & return, use parentheses instead and add a , before acc. Can someone explain to me this syntax?
unique.reduce((acc, val)=> (acc[val]=(acc[val]||0)+1, acc), {}); // { a: 4, b: 2, c: 1 }