3 ms·
Looks great. I love modern JS, and the faster everyone can move on, the better! I didn't see any async/await stuff though, is there a reason for that? I'd imag
by scottmf 9y ago
Looks great. I love modern JS, and the faster everyone can move on, the better!
I didn't see any async/await stuff though, is there a reason for that? I'd imagine it would make some code much easier to follow.
- _pmf_ 9y ago> and the faster everyone can move on, the better! Why? Where does this mindset come from?
- nailer 9y agoDirect style is easier to reason about. Control passes onto the next line consistently, for both async and sync operations. Do you really prefer callbacks or just use them because they were once necessary? Are they so good you'd use them for sync operations too? add(a, b, function(sum){ .... }) Personally: that seems like a waste of time. I'd rather just do: var sum = a + b; Likewise I'd rather do: var response = await superagent.get('https://...')
- scottmf 9y agoWhy would you want to use callbacks? Here's a code example from an npm package I was looking at, vs how I would rewrite it in modern JS: https://gist.github.com/scf4/8157abd755eb9c232e87dcc342b78b4b https://gist.github.com/scf4/8157abd755eb9c232e87dcc342b78b4... Some of it may be preference but a lot of it is objectively simpler to reason about. I don't understand why anyone would choose to make things unnecessarily complex.
- fanpuns 9y agoIf OP wrote using ES2015 then it wouldn't be included, async is defined in 2017