40

There's a popular JavaScript question What's the difference between using “let” and “var” to declare a variable?. The question has been viewed 286k times and has a score of 1468, and the top answer has a score of 2256.

The top answer contains some misinformation. It says about var and let:

Both are global if not in a block.

And also:

Global:

They are identical when used like this outside a function block.

let me = 'go'; //globally scoped
var i = 'able'; //globally scoped

This is incorrect. MDN says that:

At the top level of programs and functions, let, unlike var, does not create a property on the global object. For example:

var x = 'global';
let y = 'global';
console.log(this.x); // "global"
console.log(this.y); // undefined

OP has been notified of that fact in comments, twice:

their is a difference in global scope: let don't add property to global variable 2ality.com/2015/02/es6-scoping.html#the_global_objectYukulélé Sep 26 '15 at 10:51


let at the top level scope is not identical to var -- let explicitly will not create globally-scoped references: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…Dave Newton Mar 31 at 21:28

If you look at the revision history, you'll see that multiple users tried to correct that misinformation, but every time their edit was rolled back by the OP.

Also, that answer is incomplete—it doesn't mention TDZ at all or the fact that the same variable can't be declared twice using let.

What should we do about that? I think it's vitally important to correct that, unless we want to become the second W3Schools.

Possible solutions that IMO won't work:

  • Force the OP to edit their answer. I don't think it's a good idea, because it's their answer, and they are free to tell whatever they want in their answer.
  • Add a new, correct answer. This won't work, because the question already has many answers, and that new answer would stay at the bottom and wouldn't be noticed by many users.
21
  • 2
    Well it may be their answer but it is a community post.
    – Drew
    Commented Nov 23, 2016 at 22:58
  • 2
    @Drew It's not a Community Wiki answer. Commented Nov 23, 2016 at 22:59
  • There is an owner_id in the api stream and elsewhere, but it is a Community effort. To the extent it causes some uproar, it may be locked and mods figure it out.
    – Drew
    Commented Nov 23, 2016 at 23:00
  • 1
    @Gothdo: Have you considered putting your post material into Documentation? That's probably where it really belongs anyway.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:48
  • 2
    @RobertHarvey But people googling "let vs var" would still end up in that old question, instead of Documentation. Commented Nov 23, 2016 at 23:53
  • 3
    @Memor-X: let has never, to my knowledge, added properties to the global object. That's just not what it's for. So to the extent that the keyword exists in a given version of JS, it does not do what the answer in question says it does. (That is, this was not a breaking change introduced by ES6; it was let's semantics all along.) Commented Nov 24, 2016 at 0:03
  • 29
    @Gothdo: Rolled back. Replacing the entire post with yours was not what I had in mind. Sheesh.
    – Robert Harvey Mod
    Commented Nov 24, 2016 at 0:06
  • 10
    This question, and many members' responses to it, makes it very clear that Stack Overflow is more about popular answers, rather than correct, verifiable answers. Expressing hope that one leads to the other is, well, hope; nothing more, nothing less. This does reflect current cultural tendencies in Western societies, and therefore should be considered the correct attitude; no re-education necessary. Commented Nov 25, 2016 at 2:12
  • 1
    @NominalAnimal darn, and here I was creating a brain washing machine that made people see Justin Bieber and PHP as they really are.
    – Braiam
    Commented Nov 25, 2016 at 13:22
  • 3
    You misunderstood my point, @Braiam. You cannot fight popularity with facts. Facts are never popular. Narratives about facts are sometimes popular, but never as popular as myths. The OP's task is futile, because this site venerates popularity, with only a hope that popular answers may have some relation to facts. Facts are not important here. It does make me sad, but I deal with it, as should the OP. Pick your questions, make your answer a narrative; present a robust solution, with facts like seasoning. Some of it may stick. Expecting any better from Stack* is irrational. Commented Nov 25, 2016 at 15:54
  • 4
    @NominalAnimal so, we should just give up? That is a non-starter solution for a real problem. That we don't have the tools to address the problem at its source (education system and culture actively forming individuals incapable of being critic and inquisitive of the information given) doesn't mean that we cannot do a thing.
    – Braiam
    Commented Nov 25, 2016 at 15:59
  • 2
    @Braiam: No, just that you cannot solve the real, underlying problem here. At this site, we must abide by the site rules, it's that simple. Trying to tweak the site focus to include facts is .. not going to work. However, we do not need to take part in the popularity game: instead, we can be ourselves and do what we do, and sow the seeds for something better to grow. I've already shown my recipe above. If you cannot help but be affected by the votes and badges, go for the Unsung Hero. Commented Nov 25, 2016 at 16:09
  • 1
    How has no one mentioned the meta effect yet? If we can get 16,000 people to vote for one candidate in the primaries, surely we can round up even an eighth of that to downvote an answer?
    – BoltClock Mod
    Commented Nov 26, 2016 at 2:42
  • 4
    @BoltClock Most of these 16,000 people voted because they got a notification in their inbox, not because they saw a Meta post. Commented Nov 26, 2016 at 8:59
  • 5
    Jeebus. I'm the OP. I'm happy to fix any errors in my post. I don't think my post needs to include everything that let does, there are other answers that cover that. I just want to point out the very obvious and simple thing it does, scoping. I want to keep the deprecated section because it's funny and people like it. I don't have time to update right now, but I'm happy to when I get a chance. Thanks for all the input. Commented Nov 29, 2016 at 21:16

7 Answers 7

42

I've rolled back your duplicate closure. That's not how this works.

Using your gold badge to preempt a post that has thousands of votes and hundreds of thousands of views over some small technical point is not the way to do this. Persuade the original answer poster that your assertion is correct, so that he will persist your change on the original question.

7
  • 3
    If that's not how this works, then why users with a gold tag badge can dupehammer any question, no matter how many views or votes it has? Commented Nov 23, 2016 at 23:13
  • @Gothdo without looking at any of it (I did not), you need to balance the view count and answer count, quality, support from peers, before DH
    – Drew
    Commented Nov 23, 2016 at 23:15
  • 28
    People can be very creative about finding ways to abuse the SE platform. That doesn't make it right, nor does it compel SE to write code to deny your specific abuse creation.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:15
  • 6
    @Gothdo ok, just looked at it. You can't acquire a Gold, have a disagreement with an answer, certainly not one very highly viewed like that, then DH close to yours. Even if yours is better in your mind. A good idea is to create your Q&A and post a comment under a well received (and presumably incorrect to some degree) answer and comment nicely "Please see my answer over here [link] that ..."
    – Drew
    Commented Nov 23, 2016 at 23:22
  • 3
    This is not only "some small technical point". That answer is also incomplete—it doesn't mention TDZ at all or the fact that the same variable can't be declared twice using let. Commented Nov 23, 2016 at 23:34
  • 5
    "Persuade the original answer poster that your assertion is correct," tl;dr: downvote it to hell, @Gothdo.
    – Braiam
    Commented Nov 24, 2016 at 2:33
  • What about the follow-up?
    – Bergi
    Commented Dec 2, 2016 at 0:43
17

Make the answer a

Community wiki.

The user has rolled back pretty much all edits on that answer, even the good ones. This looks like a case of "You can't touch my answer! It's my answer!"


Since it's a CW now, I've re-applied some of the edits that were previously rolled back. The answer should now be in proper shape.

18
  • 2
    Can he still roll back, or edit? If he can, I don't see the point.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:30
  • 4
    He can still edit the answer, like anyone can, but he isn't the "owner" of the answer. This means he doesn't have the "final say" in how the answer looks. In that case, rolling back constructive edits is vandalism.
    – Cerbrus
    Commented Nov 23, 2016 at 23:32
  • 2
    Regardless, uncooperative posters are usually allowed to have their way in the case of an edit war - to my knowledge (see Gothdo's cite below). And I wouldn't make an answer community-wiki without their cooperation.
    – Aaron Hall Mod
    Commented Nov 23, 2016 at 23:33
  • 7
    @AaronHall: That's nonsense.
    – Cerbrus
    Commented Nov 23, 2016 at 23:33
  • 15
    Rolling constructive edits back is always vandalism, wiki or no. The trick is convincing the original author that they're constructive, and mods typically don't get involved in these kinds of content disputes.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:33
  • 4
    @RobertHarvey: In that case, I'd suggest having another look at the answer's history. In my opinion, the answer's OP's actions are malicious. I also don't understand why he's opposed to those improvements...
    – Cerbrus
    Commented Nov 23, 2016 at 23:34
  • 1
    I've asked the answer OP to defend his actions here. Locking the post is not ideal; it won't be maintainable at all.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:35
  • Locking? I never suggested that...
    – Cerbrus
    Commented Nov 23, 2016 at 23:35
  • That's the only thing that will prevent him from rolling back the post. CW'ing the post won't accomplish that.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:36
  • 2
    @RobertHarvey "Rolling constructive edits back is always vandalism, wiki or no." Unless such an edit "clearly conflicts with author's intent", as one of the reject reasons in the Suggested Edits review queue says. Commented Nov 23, 2016 at 23:37
  • @RobertHarvey: Shouldn't wiki-ing it send a clear enough message? In the end, the answer could really do with an edit, and the answer's OP isn't just going to let it pass, and I doubt he'll respond here, as he only ever posted 1 comment on Meta, in early 2013.
    – Cerbrus
    Commented Nov 23, 2016 at 23:41
  • 5
    I've CW'd the post.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:44
  • Much appreciated, @RobertHarvey! If it's not done yet by then, I'll have a look at the sections that require an update, tomorrow morning... removing the deprecated section, replacing the fiddle with a snippet...
    – Cerbrus
    Commented Nov 23, 2016 at 23:45
  • 5
    @TinyGiant All future reputation, not past - I believe.
    – Rob Mod
    Commented Nov 24, 2016 at 2:31
  • 1
    @AndrasDeak: That's almost correct: "The original author keeps the reputation gained (or lost) before their post entered community mode."
    – Cerbrus
    Commented Nov 25, 2016 at 8:20
11

The top answer contains some misinformation

That enough is grounds to downvotes... you don't have to look at the score to do the Right Thing™. And obviously contribute/upvote the a better answer.

9
  • 22
    Downvoting is useless. It's the top answer and has +2k upvotes. Most people will assume it's good and upvote it blindly. And the majority of the minority who notices the problem won't downvote to avoid losing rep.
    – Oriol
    Commented Nov 25, 2016 at 1:50
  • @Oriol vote for the content, forget the score.
    – Braiam
    Commented Nov 25, 2016 at 2:09
  • 1
    @Oriol this does not match my personal experience: won't downvote to avoid losing rep. The main reason I see people not downvoting is politeness.
    – ANeves
    Commented Nov 25, 2016 at 12:41
  • 2
    @ANeves screw off politeness! We want accurate information on SE, and we will have it by whatever means are necessary.
    – Braiam
    Commented Nov 25, 2016 at 13:15
  • @Braiam yes; I have that same opinion. But that doesn't negate what I wrote: that I never knew of people not downvoting in order to not lose rep. (I imagine that it happens; but IMO not often, and IMO not significantly.)
    – ANeves
    Commented Nov 25, 2016 at 14:40
  • @Braiam "whatever means are necessary" - just because that works soo good in politics? I too want to have high quality postings here, but there are other ways and if those don't work, we should think about better measures. But I'd draw a clear line del-hammering an answer without discussion in the community. That's plain self-justice! Commented Nov 26, 2016 at 16:40
  • 1
    @Olaf SE and moreover SO prefers technical accuracy over anything else, it's not "self-justice", it is towards what we aim to be: a repository of high quality curated answers to programming questions.
    – Braiam
    Commented Nov 26, 2016 at 16:55
  • 1
    @Braiam: You ignore the "be nice" policy. In my cultural surrounding, such hammers are much less nice than speaking an open word. The latter is sanctioned overly strictly. Hammers should be not? Sorry, but that sounds quite hypocritical to me. Commented Nov 26, 2016 at 17:03
  • 2
9

Downvote it

As mentioned by Martijn Pieters in a comment to this question about obsolete answers, you "downvote, comment, provide a better answer, and sit back and let time and the community do the rest".

That downvote button is sitting there, begging for you to use it to help identify useful answers. So use it!

10
  • 26
    Be realistic. 2256 downvotes?
    – Cerbrus
    Commented Nov 23, 2016 at 23:42
  • 10
    You have to start somewhere. Everest doesn't climb itself. Commented Nov 23, 2016 at 23:42
  • 5
    When you vote, you're addressing the entire post, not just some small part of it, nor the individual who posted it.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:43
  • 14
    When you vote, you are making a personal decision, how you see fit, to determine if it should be used. Even if it is just a small part of it that may cause a large problem. You may even leave a comment like "I downvoted it but will gladly reverse when you fix xyz." So there is no doctrine around here that says you have to vote based on the entire post or otherwise.
    – Drew
    Commented Nov 23, 2016 at 23:48
  • That is very true, @Drew . Minor errors can cause catastrophic programming failures later. JavaScript is highly susceptible to action-at-a-distance problems that are hard to identify and diagnose. Commented Nov 23, 2016 at 23:55
  • 2
    @Drew: Naturally, you can use your votes as you see fit (provided you don't commit voter fraud). But realistically, you didn't vote for Hillary just because you didn't like Trump's hair.
    – Robert Harvey Mod
    Commented Nov 24, 2016 at 0:01
  • When you vote, you are voting. Nothing more, nothing less. Anyone who tries to tell me I'm doing something when I'm voting other than voting, is lying to themselves, to me, and to everyone that is reading. For the record, I abstained from voting, both candidates were crap. @RobertHarvey
    – user4639281
    Commented Nov 24, 2016 at 1:46
  • 1
    Downvoting is useless. It's the top answer and has +2k upvotes. Most people will assume it's good and upvote it blindly. And the majority of the minority who notices the problem won't downvote to avoid losing rep.
    – Oriol
    Commented Nov 25, 2016 at 1:50
  • Downvoting is too blunt an instrument for this situation. That's why I'm downvoting this. (Ha, see what I did there... But yeah, seriously.) Commented Nov 25, 2016 at 12:49
  • 1
    Mention the answer on Reddit and see if you get enough downvotes ;-) Commented Nov 26, 2016 at 2:47
-7

Possible solutions that IMO won't work:

  • Force the OP to edit their answer. I don't think it's a good idea, because it's their answer, and they are free to tell whatever they want in their answer.

  • Add a new, correct answer. This won't work, because the question already has many answers, and that new answer would stay at the bottom and wouldn't be noticed by many users.

Actually, I have successfully supplanted several highly upvoted answers. It takes years. Sometimes some brow beating from others (just don't do it yourself - that just looks bad, and I've made that mistake before).

But it happens, and it's doubly good because you get the credit. The only people who suffer are the poor users looking for quick answers and going with the first thing they see.

Another thing you can do is comment on the answer regarding its inaccuracies. As long as the comment is correctly critiquing the answer in its current form (barring any other issues with the comment) the comment should not be deleted.

One more thing you can do is downvote the answer. For answers with hundreds (thousands?) of upvotes, it's not much, but it's something, and as downvotes rack up, if they don't get the attention of the poster, at least it signals the problem to those with the privilege to see the gross up and downvotes.

(If only we had a way to sort by some kind of answer "hotness" metric... but that's a feature request, for another post.)

16
  • 4
    "It takes years." So during all these years Stack Overflow will be spreading misinformation? Commented Nov 23, 2016 at 23:27
  • 1
    It's how the site works - the best answers rise to the top. They just don't say how long it takes. Nevertheless, you can comment about the innaccuracies on the answer - moderators should not delete comments that correctly critique an answer in its current form.
    – Aaron Hall Mod
    Commented Nov 23, 2016 at 23:28
  • 4
    @Gothdo to save you the suspense, SO is spreading a ton of misinformation in the wild guess answers that exist under many questions.
    – Drew
    Commented Nov 23, 2016 at 23:29
  • 2
    @Drew But that doesn't mean that we shouldn't try to minimize the amount of misinformation. Commented Nov 23, 2016 at 23:32
  • Like I said in a comment under Harvey's, post a comment pointing to your answer and explain nicely.
    – Drew
    Commented Nov 23, 2016 at 23:32
  • 12
    "The only people who suffer are the poor users looking for quick answers and going with the first thing they see." So, only the main audience of the site. No big deal, y'know. Everything's fine, hunky-dory, signal-noise ratio is just great as long as you ignore all the misinformation thrown in your way…. SO should be better than this. Commented Nov 24, 2016 at 0:01
  • 1
    @NathanTuggy The site knows it's an issue. What do you think would solve this? Unpinning accepts after a year? Providing for a hotness sort? I think those things could solve it.
    – Aaron Hall Mod
    Commented Nov 24, 2016 at 0:25
  • 3
    @AaronHall: I prefer making accepted answers fit into normal sorting, probably with an additional +1.5 virtual score based on the checkmark, which guarantees that they would be sorted above any other answers with the same score or up to one higher. Commented Nov 24, 2016 at 0:31
  • @NathanTuggy what about the really old answers with thousands of upvotes - that just aren't really very good at all?
    – Aaron Hall Mod
    Commented Nov 24, 2016 at 0:54
  • 3
    @AaronHall: Well, I do have to admit Wilson scoring might be nice as well. Oh, and if we can ever get deprecation voting to work, that might be handy too. Commented Nov 24, 2016 at 1:02
  • Wouldn't a "hotness" sort (that maybe only considers votes over the past year) solve the problem?
    – Aaron Hall Mod
    Commented Nov 24, 2016 at 1:03
  • Does the average meta voter really believe there's a problem with addressing such an old and upvoted answer by 1) writing your own better answer, 2) writing a comment addressing the issue, and 3) downvoting it?
    – Aaron Hall Mod
    Commented Nov 24, 2016 at 14:58
  • I think it is more about the idea that those things are essentially meaningless on heavily upvoted posts. A drop of water in the ocean so to say. Basically, yes those are the acceptable options in most cases. In most cases said answer doesnt have a score greater than 2000.
    – user4639281
    Commented Nov 25, 2016 at 1:14
  • @AaronHall "What do you think would solve this?" This problem was solved 80 years ago.
    – Oriol
    Commented Nov 25, 2016 at 1:58
  • @Oriol I think that gives a single downvote too much weight - I'd rather weight by time.
    – Aaron Hall Mod
    Commented Nov 25, 2016 at 2:12
-16

How about correcting the misinformation and then locking the post because of "content dispute" or suspending the user who insists on keeping misinformation visible for "low quality contributions"?

4
  • 3
    Why would we do that?
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:06
  • 1
    @RobertHarvey Because moderation tools are (as the name implies) just tools that we use to make Stack Overflow the best library of programming problems & their solutions on the Internet and keep it that way. Making sure canonical answers contain absolutely no misinformation is a critical part of that. Commented Nov 23, 2016 at 23:13
  • If you feel strongly about it, cast a flag against the post. Don't expect to get a good reception, however; mods don't generally get involved in these sort of content disputes, and your flag is likely to be declined.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:21
  • 1
    That's not what content dispute lock is for.
    – user6820627
    Commented Nov 25, 2016 at 1:30
-36

I think the best solution is to create a new canonical Q&A, and close the current question as a duplicate of it. And so I did. I'll now let the community express their opinion on the quality of the new Q&A by voting on it, and if the feedback will be mostly negative, I will reopen the original question and delete the new one.

5
  • 24
    Mighty convenient, this meta thing is, isn't it? Allowing you to publicize your new, "clearly superior" post over one that has thousands of votes and hundreds of thousands of views, without even waiting for feedback from the community. I'm not impressed.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 22:56
  • 1
    @RobertHarvey I thought that posting a question on Meta is the right way to get community feedback. Besides, the fact that I have a gold JavaScript badge might indicate that I have a good knowledge in that topic and my Q&A is indeed superior. Commented Nov 23, 2016 at 23:16
  • 21
    You didn't wait for feedback; you just did it.
    – Robert Harvey Mod
    Commented Nov 23, 2016 at 23:19
  • 1
    (1/2) Just a note on your answer that it is also a bit misleading, can't comment there because it is locked. At the top level, variables declared using let don't become global variables. What you mean is "At the top level, variables declared using let don't get added to the scope object". They are global variables, as they are variables which are available globally, you just cannot access them through the scope object. However, this is still misleading, as it is implying that, at any other level, you can expect a different behavior.
    – user4639281
    Commented Nov 24, 2016 at 1:56
  • 1
    (2/2) This is incorrect because in all circumstances, the variable will not be accessible through the scope object if declared using let. See { var hello = 'world'; let foo = 'bar'; console.log(this.hello, this.foo) /* "world", undefined */}. So instead of At the top level, variables declared using let don't become global variables. you should have written Variables declared using let will not be added to the scope object
    – user4639281
    Commented Nov 24, 2016 at 1:58

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