Javascript language

adplus-dvertising
eval() Method in JavaScript
Previous Home Next

Evaluates or executes an argument

If the argument is an expression, eval() evaluates the expression

If the argument is one or more JavaScript statements, eval() executes the statements

Syntax:

eval string

For example

<html>
<body>
<script language="javascript">
function fun_name(){
   var full_name = 'Aditya Tiwari';
   var mySentence = eval('"My name is " + full_name');
   alert(mySentence); 
}
</script>
<button onclick="fun_name()">Eval function</button>
</body>
</html>

Output:

floor()Method

The floor() method rounds a number to the nearest integer, and returns the result.

syntax:
Math.floor (value) 

For Example

<html>
<body>
<script language="javascript">
function math_val(){
   var val = 1.1;
   var stat = eval('"Actual value is=" + val +"  
	 "+ "After truncate value is= " + Math.floor(1.1)');
   alert(stat); 
}
</script>
<button onclick="math_val()">FLOOR</button>
</body>
</html>

Output:

Previous Home Next