<html>
<body>
<script type="text/javascript">
document.write("<br />" + eval("2+2"));
</script>
</body>
</html>
This gives me output as 4.
If i remove the eval function and run the same thing know it gives me the same output that is 4
<html>
<body>
<script type="text/javascript">
document.write("<br />" + (2+2);
</script>
</body>
</html>
eval()takes a string and evaluates it as if it wasn’t one.(2+2)is not a string.