What does putting a minus sign in front of a function do?
For example:
return order === 'desc'
? (a, b) => descendingComparator(a, b, orderBy)
: (a, b) => -descendingComparator(a, b, orderBy);
What does putting a minus sign in front of a function do?
For example:
return order === 'desc'
? (a, b) => descendingComparator(a, b, orderBy)
: (a, b) => -descendingComparator(a, b, orderBy);
It negates the value that descendingComparator(a, b, orderBy) returns, just like the - in -x negates the value that x contains. In context, what it's doing is reversing the order of the sort (presumably this is within an array sort callback or similar).