eval() 함수는 JavaScript 코드를 포함하는 문자열 값을 허용합니다. 이 함수는 주어진 코드를 실행하고 코드의 결과를 반환합니다.
구문
구문은 다음과 같습니다.
eval(32*45);
예시
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
document.write(eval(32*45));
document.write("<br>");
document.write(eval(new String("Hello welcome to Tutorialspoint")));
</script>
</body>
</html> 출력
1440 Hello welcome to Tutorialspoint