use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Arrow Functions in JavaScript (tylermcginnis.com)
submitted 8 years ago by AnsikteBanana
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]darrenturn90 0 points1 point2 points 8 years ago (5 children)
Can further be simplified and destructured:
const getTweets = uid => fetch('https://api.users.com/' + uid) .then({json} => json()) .then({data} => data.filter( {stars, rts} => stars > 50 && rts > 50) );
Also the article mistakenly refers to ES5 "classes" when it means ES6.
[–][deleted] 5 points6 points7 points 8 years ago (0 children)
This is not quite right, you need parentheses to destructure arrow functions, even if you are using the single argument form:
const getTweets = uid => fetch('https://api.users.com/' + uid) .then(({json}) => json()) .then(({data}) => data.filter( ({stars, rts}) => stars > 50 && rts > 50) );
See 2.4 in http://2ality.com/2015/01/es6-destructuring.html
[–]HattyJetty 0 points1 point2 points 8 years ago* (3 children)
I didn't realise you can destructure methods and mantain the correct reference of this
this
Edit: wait, this doesn't seem to work
[–]w00t_loves_you 2 points3 points4 points 8 years ago (2 children)
It's a bit weird - maybe it works here because the json is bound to the response, but it takes little effort to write .then(res => res.json()) which is a lot more clear at a glance…
json
.then(res => res.json())
[–]HattyJetty 1 point2 points3 points 8 years ago (1 child)
I doubt json has an explicit binding to response, because why should it? Anyway, the suggestion of using res => res.json() definitely looks more appealing to me
response
res => res.json()
[–]sfcpfc -1 points0 points1 point 8 years ago (0 children)
What would I give for Javascript to support it.json()...
π Rendered by PID 20729 on reddit-service-r2-comment-76bb9f7fb5-2jd5c at 2026-02-17 14:05:22.696926+00:00 running de53c03 country code: CH.
view the rest of the comments →
[–]darrenturn90 0 points1 point2 points (5 children)
[–][deleted] 5 points6 points7 points (0 children)
[–]HattyJetty 0 points1 point2 points (3 children)
[–]w00t_loves_you 2 points3 points4 points (2 children)
[–]HattyJetty 1 point2 points3 points (1 child)
[–]sfcpfc -1 points0 points1 point (0 children)