Thursday 11 April 2013

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

WTAD Practical -1 :
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>


WTAD Practical  1


For all WTAD programs wtad-practicals.html
To get all programs in your inbox.Enter your email

Kindly Bookmark and Share it:

0 comments :

Post a Comment

Any Query ? any suggestion ? comment here

 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT