Javascript Type Conversion

Javascript Type Conversion 

Type Conversion is automatically carried out in javascript.  Normally automatic conversion happen normally in relational operators.

Type conversion is the act of converting data of one type into a different type  .  It occurs automatically in javaScript when you change the type of data stored in a variable.

var  a=”3.56”;

a= 3.56;

Type of  a changes from string to number. Besides the automatic conversion inherent in a javaScript . We can also convert one data type to another data type using different method.

toString(), parseInt();

Example of Javascript Type Conversion :- 

<html>
<head>

<script>
document.write(parseFloat(“7.8888″) +”<br>”);
document.write(parseFloat(“92bb”)+”<br>”);
document.write(parseFloat(“12edf2″)+”<br>”);
</script>

</head>
<body>
</body>
</html>

Result of Javascript Type Conversion :-

 

javascript-type-conversion




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top