What is the JavaScript variable scope in a switch / case statment?
- by Todd Moses
While creating JavaScript with ASP.NET MVC I noticed several scope warnings and realized that I am missing something with understanding the variable scope inside the switch / case statement.
Warning: 'i' is already defined referring to case b and case c
My code looks similar to this:
switch(element) {
case 'a':
for(var i=0; i < count;…