Demonstrate that variables created by the var statement are not affected by the delete operator in JavaScript
Description
The following code shows how to demonstrate that variables created by the var statement are not affected by the delete operator.
Example
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var theDate = new Date();<!-- www.ja v a 2s . c o m-->
document.write("theDate=",theDate,"<br>Deleting theDate!<br>");
delete theDate;
document.write("theDate=",theDate);
</script>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Variable
Copy reference during assignment for object...
Copy value from one primitive type to anoth...
Create a code with three level of execution...
Define a variable outside a function and ca...
Demonstrate that there are no Block-Level S...
Demonstrate that variable defined with var ...
Demonstrate that variable defined without v...
Use eval to evaluate dynamic expressions in...
Use typeof operator to check if a variable ...
Copy reference during assignment for object...
Copy value from one primitive type to anoth...
Create a code with three level of execution...
Define a variable outside a function and ca...
Demonstrate that there are no Block-Level S...
Demonstrate that variable defined with var ...
Demonstrate that variable defined without v...
Demonstrate that variables created by the v...
Find out the difference between primitive w...Use eval to evaluate dynamic expressions in...
Use typeof operator to check if a variable ...