We can use it to shorten codes in some cases.
let result;
if (condition) {
doSomething();
result = value;
} else {
result = other;
}
const result = condition ? (doSomething(), value) : other;
const arrowFn = (arg) => {
doSomething();
return result;
};
const arrowFn = (arg) => (doSomething(), result);
const countOccurrences = (arr) => arr.reduce((p, c) => ((p[c] = ++p[c] || 1), p), {});
countOccurrences([2, 1, 3, 3, 2, 3]);
const chunk = (arr, s) => arr.reduce((a, e, i) => (i % s ? a[a.length - 1].push(e) : a.push([e]), a), []);
chunk([1, 2, 3, 4, 5, 6, 7, 8], 3);