4 ms·
Because it's the first time you've seen JS lambdas, the "html`foo`" syntax, and/or JS string interpolation? This function looks perfectly 100% normal to me, bu
by TeMPOraL 7y ago
Because it's the first time you've seen JS lambdas, the "html`foo`" syntax, and/or JS string interpolation?
This function looks perfectly 100% normal to me, but that's probably I spent a whole workweek once almost entirely in ObservableHQ documents, where you'd use md`...`, html`...`, etc. all the time.
- rbanffy 7y agoIt's not the first time I see JS lambdas, or lambdas. I'm just not sure why let f = (a, b) => a + b can be considered prettier (or clearer) than let f = function (a, b) { return a + b } or (given the differences in runtime behavior) function f (a, b) { return a + b } It saves typing for trivial functions, sure, but it's yet another syntax for the same thing.
- spankalee 7y agoI prefer it for 1) Less tokens: less noise, more signal. `a + b` is the important part, let's not obscure it. 2) Lexical `this` binding. 3) Shorter and less likely to line-break. 4) No hoisting when used with let and const 5) Actually const when used with const. const module exports are faster.
- thrower123 7y agoI've come to like the arrow-function lambda syntax, but that's mostly because it is exactly what C# uses, and I write vastly more lambdas for LINQ and higher-order functions on the back-end than I do in JS. The only downside is you've got to involve babel to transpile it down to the shitty old browser versions that we need to support, so you go from a simple reload to a webpack or grunt invocation that takes 30 seconds to a couple minutes, depending on how invasive the corporate anti-virus is feeling today.
- spankalee 7y agoJust don't compile during development. Only compile for testing on and differential serving to legacy browsers.