This will be the correct syntax:
switch(response.Errors.key1) { case 'afkafk': alert('test'); break; default: alert('default'); }
But I suspect that in your case the following structure is more adapted:
{ Errors: { key: 'key1', message: 'afkafk' }, IsValid: false, SuccessMessage: '' }
because it allows you to enable the key:
switch(response.Errors.key) { case 'key1': alert(response.Errors.message); break; default: alert('default'); }
source share