I was fixing a bug this morning and came across this strange quirk in eval
.
If you try to evaluate:
var e = "true true"; console.log(eval(e));
.
The console throws an exception, but if you add a line break between the two conditions:
var e = "true\n true"; console.log(eval(e));
The console returns true.
I know eval
is evil and I've solved the problem by stripping out the newlines, but I was wondering why this difference occurs. I had a quick Google for newlines and eval but came up with nothing.