'eval()' Example : Eval « Document « JavaScript DHTML






'eval()' Example

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

    
      
        
  








Related examples in the same category

1.Use eval function to run statement dynamically