4

I recently dupehammered the question When do you use return () in ES6 to What's the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript? I think the main problem of the OP is that they don't know the arrow function syntax. However, another person with a gold JavaScript tag badge reopened this question and claims that this question is not about arrow functions, but about why would someone want to return a function. Even if that's true, IMO it's still too broad and primarily opinion-based.

Should this question be closed?

9
  • 1
    I do agree with the user that the original duplicate doesn't apply, for exactly the reasons that they provided. The question pretty clearly understands that it is used to create a function, they just don't understand the idea of returning a function.
    – Servy
    Dec 5, 2016 at 19:19
  • As @Servy argues, I'd say it is not a duplicate of the suggested question. It is not primarily opinion-based either ("Why would you want the function block returned?" is, in this context, equivalent to "Why is it useful to return a function block?"). "Too broad" possibly applies (though the existing answers kind of cover the essentials, it is debatable they would be enough for the OP, or, for that matter, for anyone else completely unfamiliar with first-class functions). My guess would be that there is a better duplicate somewhere else -- the hard part is finding it...
    – duplode
    Dec 5, 2016 at 19:34
  • 1
    @duplode Maybe one of these?
    – Bergi
    Dec 5, 2016 at 19:38
  • 1
    @Bergi From a quick glance, this and this look like decent candidates, though the framing of the issue isn't quite ideal.
    – duplode
    Dec 5, 2016 at 19:45
  • @duplode I think the first one is perfect. Unfortunately I already voted as too broad…
    – Bergi
    Dec 5, 2016 at 19:48
  • I'm agreeing with @Servy on this one; the user doesn't seem to grasp why they want to return a function. It's probably a bit on the broad side, since "why" could be categorically answered with, "it depends on what you're doing". The main thing that we're at least agreeing on is that it's close-worthy, but the unnecessary duplicate pointing to an unhelpful resolution isn't ideal.
    – Makoto
    Dec 5, 2016 at 19:52
  • @Bergi Gothdo has just mentioned that in an "alternate duplicate" comment. It is somewhat annoying that the question was closed again with the "wrong" duplicate by someone else, though.
    – duplode
    Dec 5, 2016 at 20:06
  • @Makoto Not directly related to this question, but I'm puzzled why you would think that an answer of "it depends" necessarily means the question is "broad". The canonical form of such questions is "Is it better to use A or B?". Such a question could be perfectly bounded, and have an answer such as "if you want to do A', then use A, but if you want to do B', then use B". I'm on a quixotic campaign against what I feel is overuse of the "too broad" or "opinion-based" reasons, which are being used for everything from "no code" to "too basic".
    – user663031
    Dec 12, 2016 at 18:22
  • 1
    @torazaburo: I'm not trying to draw a heuristic here, I'm basing my opinion off of the question as it stands. From how the code reads now, there's little incentive to bother with returning a function, so the reason I stated "it depends" would be due to that being a purely design principle. If the OP were asking how to return a function, that'd be a different matter altogether - it wouldn't be broad and the duplicate would help - but since they're asking why, that's why it's too broad; we can't reasonably answer why one would want to do it unless there's some design mandate for it.
    – Makoto
    Dec 12, 2016 at 21:05

1 Answer 1

5

It's obvious that OP doesn't know what an arrow function is; otherwise OP wouldn't have asked the question thinking that there's such a thing as return ().

The question should be closed as a duplicate, and if OP still has questions those should go in a new question, while trying to better clarify what OP doesn't understand.

5
  • 1
    The question is asking why you would want to return a function. If he didn't understand that => was used to define a function, then why would he be asking why one would want to return a function?
    – Servy
    Dec 5, 2016 at 20:08
  • @Servy That's my opinion, let's see what OP says.
    – Maroun
    Dec 5, 2016 at 20:10
  • It's your idea that someone who didn't know that they were creating an inline function would ask why some code would be creating an inline function. How could they possibly know to ask that if they didn't know what the operator is? What is the basis for that opinion, given that the OP demonstrated they understood exactly what you're claiming they don't understand?
    – Servy
    Dec 5, 2016 at 20:12
  • 3
    @Servy They ask why one would want to return a function because running this code logs a function. This doesn't mean that they understand how this code works, and the use of phrases like "the use of return ()" and "function block" clearly shows that they don't know what an arrow function is. Dec 5, 2016 at 20:27
  • I think an answer of pointing out "you should not group the syntex as return ()..." and then link to the current duplicate would be more clear than just mark as duplicate
    – ggrr
    Dec 6, 2016 at 3:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .