What command I must use, to get out of the for loop, also from //code inside
jump direct to //code after
//code before
for(var a in b)
{
switch(something)
{
case something:
{
//code inside
break;
}
}
}
//code after
use another variable to flag when you need to exit:
var b = { firstName: 'Peter', lastName: 'Smith' };
var keepGoing = true;
for (var a in b) {
switch (true) {
case 1:
keepGoing = false;
break;
}
if (!keepGoing) break;
console.log('switch end');
}
console.log('for end');