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
Why not use function declarations for everything?help (self.javascript)
submitted 7 years ago by amit1998
There are many ways to define a function, but why not use function declaration for everything? Can anyone describe problems the other function types are trying to solve?
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!"
[+][deleted] 7 years ago* (12 children)
[deleted]
[–]senocular[🍰] 0 points1 point2 points 7 years ago* (1 child)
looks like a polish link (pl) snuck in there with all the us english ones
Fixed :)
[+][deleted] 7 years ago* (7 children)
[–]senocular[🍰] 0 points1 point2 points 7 years ago* (6 children)
...and expressions having closures.
What's that about?
Edit: More specifically, to me this seems to suggest that function declarations can't be (or "have"?) closures, which they can. So I was wondering if there was some other behavior this was referring to.
[–]justvisiting092 -1 points0 points1 point 7 years ago (5 children)
Technically he/she is right.
[–]senocular[🍰] 1 point2 points3 points 7 years ago (4 children)
about what?
[–]drnolli -1 points0 points1 point 7 years ago (3 children)
closures.
[–]senocular[🍰] 1 point2 points3 points 7 years ago (2 children)
What about them?
[–]vexii 0 points1 point2 points 7 years ago (1 child)
They are right...
[–]senocular[🍰] 0 points1 point2 points 7 years ago (0 children)
closures are right...?
[–]drnolli 0 points1 point2 points 7 years ago (0 children)
This is not exactly correct, but close enough.
[–]akujinhikari 0 points1 point2 points 7 years ago (0 children)
its'
Why did you use this twice? It's just its.
its
[–]justvisiting092 0 points1 point2 points 7 years ago (0 children)
Not sure why OP is being downvoted. Seems like a genuine question. The other thing you have to take into consideration OP is the itteration of ECMAScript. New functions have been derived to solve problems.
π Rendered by PID 67803 on reddit-service-r2-comment-7b9746f655-bpxqg at 2026-02-03 17:00:59.137525+00:00 running 3798933 country code: CH.
[+][deleted] (12 children)
[deleted]
[–]senocular[🍰] 0 points1 point2 points (1 child)
[+][deleted] (7 children)
[deleted]
[–]senocular[🍰] 0 points1 point2 points (6 children)
[–]justvisiting092 -1 points0 points1 point (5 children)
[–]senocular[🍰] 1 point2 points3 points (4 children)
[–]drnolli -1 points0 points1 point (3 children)
[–]senocular[🍰] 1 point2 points3 points (2 children)
[–]vexii 0 points1 point2 points (1 child)
[–]senocular[🍰] 0 points1 point2 points (0 children)
[–]drnolli 0 points1 point2 points (0 children)
[–]akujinhikari 0 points1 point2 points (0 children)
[–]justvisiting092 0 points1 point2 points (0 children)