如果bool
变量被定价,我试图打破foreach:
$.each(GlobalVariables.availableServices, function(index, service)
{
if(state == true){ break; }
for (var k = 0; k < appointment.id_services.length; k++)
{
if(actual_option == appointment.id_services[k].id)
{
serviceDuration = serviceDuration - parseInt(service['duration']);
state = true;
break;
}
}
});
但是我收到了这个错误:
Uncaught SyntaxError:非法中断语句
在这一行:
if(state == true){ break; }
为什么会这样?