Breaking News
yeni film izle hd film seyret film izle

null & undefined In Java Script

Null type has only one value, null. The null value means ‘no data’ or this variable do not have any useful data.
 
Undefined type has one value, undefined, undefined means nothing is stored in this variable. Undefined is not even null.
 
Initializing null type variable
 
var food = null
var is JavaScript keyword, food is a variable namenull  is value assigned to food variable.
 
In the example given below we have used keyword document.write (message ) which is used to printthe message or variable value given with it.
 
Example 1
 
<html>

<head>

</head>

<body>

<script type=”text/JavaScript”>

var food=null

document.write(“food is  : “+food);

</script >

</body>

</html>

 
 
Understanding the program
 
food is a variable of null type having no type of values or data.
 
output of this program
food is : null
click here to view result of this program in browser
 
Knowing undefined  type  variable
var  food ;
var is JavaScript keyword, food is a variable name,  no value is  assigned to  variable food.
 
In the example given below we have used keyword document.write (message ) which is used to print the message or variable value given with it.
 
Example 2
 
<html>

<head>

</head>

<body>

<script type=”text/javascript”>

var food;

document.write(“food is  : “+food);

</script >

</body>

</html>

 
 
Understanding the program
 
food  is  a variable  of  undefined   type , because nothing is defined to it .
 
Output of this program
food is : undefined

Check Also

Recursive Functions In Java Script

A function which calls itself, is called a recursive function. When A function calls itself …