Why doesn't this alert("Summer")?
eval('(caption="Summer";alert(caption))');
Does it have something to do with the quotes in "Summer"?
Why doesn't this alert("Summer")?
eval('(caption="Summer";alert(caption))');
Does it have something to do with the quotes in "Summer"?
The extra parentheses are wrong, this is correct:
eval('caption="Summer";alert(caption)');
Uncaught SyntaxError: Unexpected token ;
The outer parentheses make no syntactical sense. Try this:
eval('caption="Summer";alert(caption)');
Chrome console:
eval('(caption="Summer";alert(caption))')
SyntaxError: Unexpected token ;
This works:
eval('caption="Summer"; alert(caption)')
A more better way to do this and avoid syntax problem is to do following,
eval(function(){var x="test"; alert(x)}());