Undefined example:- JavaScript




A variable declared but the value is not assigned that is called undefined property.

Code:-

<!DOCTYPE html> 
<html> 

<head> 
 <meta name="viewport" content="width=device-width, initial-scale=1"> 

 <script> 
  /* 
      The variable is declared but not initialized, then it returne undefined 
    */ 
  function cal_fun() 
  { 
   var test; 
   alert(test); 
  } 
 </script> 

</head> 

<body> 
 <h2>undefined</h2> 

 <button onclick="cal_fun();">Get Value</button> 

</body> 


</html>
Undefined example:- JavaScript Undefined example:- JavaScript Reviewed by Network security on November 11, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.