postheadericon 1. Write a JavaScript that shows how a variable’s type can be changed on-the-fly.



<html>
<head>
<title>EX-1: WTAD : www.bipinrupadiya.com</title>
</head>
<body>
<h1>
<script type="text/javascript">

var myVar=10;
document.write("<br>myVar : ["+myVar +"] Type : ["+typeof(myVar)+"]<br>");
myVar=12.5;
document.write("<br>myVar : ["+myVar +"] Type : ["+typeof(myVar)+"]<br>");
myVar='c';
document.write("<br>myVar : ["+myVar +"] Type : ["+typeof(myVar)+"]<br>");
myVar=true;
document.write("<br>myVar : ["+myVar +"] Type : ["+typeof(myVar)+"]<br>");
myVar="Bipin Rupadiya";
document.write("<br>myVar : ["+myVar +"] Type : ["+typeof(myVar)+"]<br>");
</script>
</body>
</html>

0 comments:

Follow by Email

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.