3 ms·
You can also use the comma operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator https://developer.mozilla.org/en
by wonnage 5y ago
You can also use the comma operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
`const upperCase = (message) => (console.log(message), message.upperCase())`
The function body needs to be in parens. Maybe not the most useful for this case, but I've used this when setting logpoints in Chrome to log a variable and save it to a global for further inspection.
- skywal_l 5y agoYes, useful when trying to debug functional style chaining: const result = array .map(someFunction) .filter(someOtherFunction) .map(x => (console.log(x), x)) // debug here .map(stillAnotherFunction);