News for hackers. Stuff that matters.
Re:Removing jQuery from GitHub.com frontend by Ajedi32 on Wednesday July 25, 2018 @09:42PM (#17614490)
For comparison, here's the first example, but using fetch:

    fetch('/my/url').then((r) => r.json()).then((data) => {

    })
And as an added bonus, fetch uses promises, so in an async function that's just:

    let data = await fetch('/my/url').then((r) => r.json())
Re:Removing jQuery from GitHub.com frontend by Cthulhu_ on Thursday July 26, 2018 @05:41AM (#17616201)
I'm not a fan of mixing await and .then myself;

    let data = await (await fetch('/my/url')).json();
That's a one-liner, but you can split the request and json data as well (and you usually want to anyway because of error handling).
Re:Removing jQuery from GitHub.com frontend by aloisdg on Thursday July 26, 2018 @02:31AM (#17615450)
You can write `(r)` like this `r`. Remove clutter. You don't write `let i = (0)`
Re:Removing jQuery from GitHub.com frontend by klodolph on Thursday July 26, 2018 @07:54AM (#17616710)
That’s not a good analogy at all, the () is there in arrow functions always except, as a special case, it’s optional if there’s a single argument.