Search This Blog

Thursday, 6 September 2012

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


Filename-js1.html

<html>
<body>
<script language="javascript">
a=10;
document.write("a="+ a +"type="+typeof a+"<br>");
a="hello";
document.write("a="+ a +"type="+typeof a+"<br>");
</script>
</body>
</html>
Output
a=10type=number a=hellotype=string

No comments:

Post a Comment