Javascript - Why are declarations in exclusive if clauses considered duplicate?

javascript, scope

Solution

Variables in JavaScript are by default bound to function scope, not to block scope. Variables defined inside blocks are hoisted to function scope, which is a very common source of errors. and exactly what happens in your case too.

Variables can be declared in block scope with `let` keyword although this requires JavaScript 1.7.

Problem

With the following JavaScript ``` if (someCondition){ var x = ...; //Resharper warns that this is a duplicate declaration } else { var x = ...; //Resharper warns that this is a duplicate declaration } ``` But the scopes are different? Why does this matter? Is this exclusive to JavaScript? I get no such warning with equivalent code in C#. Or -- Is it an erroneous Resharper warning?

Original source

Related problems