Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Samual Sam

The eval() function accepts a string value which holds JavaScript code. This function executes the given code and returns the result of the code.

Syntax

Its Syntax is as follows

eval(32*45);

Example

Live Demo

<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>

Output

1440
Hello welcome to Tutorialspoint

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.