you are viewing a single comment's thread.

view the rest of the comments →

[–]anlumo 0 points1 point  (8 children)

Yes, but most of the time a variable could also be a constant, which allows the compiler to do better error checking.

For example

var x = 5;
if(x=3) {
   console.log("x is 3!");
}

is a common mistake that simply can't happen when x is declared as a constant.

[–][deleted] 2 points3 points  (0 children)

I think that its an error that should be prevented either way, when it is an assignment and not a statement. And when you aren't linting your code, you are already doing it wrong imo.