WTAD Practical -1 :
Write a JavaScript that shows how a variable’s type can be changed on-the-fly.
Write a JavaScript that shows how a variable’s type can be changed on-the-fly.
<HTML>
<HEAD>
<TITLE>WTAD.practical-1 @iAmLearningHere </TITLE>
</HEAD>
<BODY>
<H4>See the Variable Type is changing .. !!</H4>
<script type="text/javascript">
var p1 = 11;
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+ typeof(p1) +"<br>");
p1 = 11.1;
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+ typeof(p1)+"<br>");
p1 = 'i';
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+typeof(p1)+"<br>");
p1 = true;
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+typeof(p1)+"<br>");
p1 = "iamlearninghere";
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+typeof(p1)+"<br>");
</script>
<br>
NOTE :: Javascript variable changes type according the value assigned
</BODY>
</HTML>
<HEAD>
<TITLE>WTAD.practical-1 @iAmLearningHere </TITLE>
</HEAD>
<BODY>
<H4>See the Variable Type is changing .. !!</H4>
<script type="text/javascript">
var p1 = 11;
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+ typeof(p1) +"<br>");
p1 = 11.1;
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+ typeof(p1)+"<br>");
p1 = 'i';
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+typeof(p1)+"<br>");
p1 = true;
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+typeof(p1)+"<br>");
p1 = "iamlearninghere";
document.write("<br>p1 contains ::"+ p1 +" of Type :: "+typeof(p1)+"<br>");
</script>
<br>
NOTE :: Javascript variable changes type according the value assigned
</BODY>
</HTML>
0 comments :