When I run the code below on Chrome, the console shows an Unexpected identifier exception.
var a = true;
var b = false;
switch (true) {
a:
window.alert('test A');
break;
b:
window.alert('test B');
break;
default:
window.alert('test C');
}
I tried to run the code directly on console to guarantee the error is not caused by other line on my script, but I’m still receiving the exception.
I also looked for an answer through Google, but didn’t found any answer for this strange behaviour.
Thanks.
you can’t write
b:you must writecase b: