by flohofwoe · 1y ago · 0 comments
const add = (a: i32, b: i32): i32 => a + b;
...or any variation of the arrow-function idea...A "function" keyword often exists just to help the parser. C3, for example, to simply the parser of its language that's a superset of C, adds a "fn" keyword for this very purpose of disambiguation.
function add(a: i32, b: i32): i32 {
return a + b;
}
Than the example you provided and it is approximately the same length. I used to arrow functions everywhere in TS/JS and it made it difficult to read IME, and there was zero benefit. They are find for things like event handlers, promises chains etc. But I'd rather just use function when I don't have to worry about the value of this.