This is a new series where I review a programming book I have read. I will usually issue a review within a few days of reading it. This one is late because I just decided to do this series.
var and how and when to use them.
This was an issue in the first book as well. I understand some of the quirks when using syntactic sugar such as
const especially when destructuring arrays. But we are far safer for them than we are without them.
Here is a bit of what I am talking about on this issue:
just realized a quirky limitation of let/const that doesn't apply to var:
var [ a = 1, a = 2 ] = foo() // ok
let [ b = 1, b = 2 ] = bar() // error
let c; [ c = 1, c = 2 ] = baz() // okOctober 4, 2018
This is a legitimate concern. But the conversation that followed made me question Kyle’s openness to new ideas:
i think you all overeached a bit in trying to save us from these "errors" -- which aren't actually errors. that kind of stuff is useful from opt-in linters. but the language shouldn't have been so opinionated. shrugs.October 4, 2018
Ben Lesh, who is a fantastic champion of RxJS and functional programming tweeted this:
Most respectable linters disallow var anyway. 🤔
And I'm with @awbjs, const and let are saving us here, I've seen and even written this bug with var in my 20+ years. I guess I'm just not awesome. 🤷♂️October 4, 2018
Admittedly, he could have avoided the passive aggressive jab at Kyle at the end but I agreed with this tweet.
That’s the first in the series. ↩