I pass in an array of error messages to parse. An example input would be:
\"An item with this x Id already exists.
An item with this y id already exists.
An it
You are getting Error!
in end because the splitting is giving you empty line ""
and when you check for it with if(!aLines[i])
it returns true
because it is empty/null/nothing. You can check it here in a fiddle, you remove the empty line from end and it does not go over array 4 times.
I have also put in following code which shows alert:
var a="";
if(!a){
alert("!a");
}