Breaking News
yeni film izle hd film seyret film izle

Conversion to Number In Java Script

Conversion to Number means a Boolean or string type variable is changing it’s type to Number. In JavaScript a variable can contain any type of data and the data contained by the variable represents the type of that variable. Type conversion in JavaScript is done implicitly . The conversion to Number is very easy it could be seen by below given program.




<script type=”text/javascript”>

var a,b,c;

c= false

b= “23”


document.write(“<br>Value of c “+c);

document.write(“<br>Value of b “+b);

document.write(“<br>Value of a “+a);

document.write(“<br>Data type of c “+typeof(c));

document.write(“<br>Data type of b “+typeof(b));

document.write(“<br>Data type of a “+typeof(a));


document.write(“<br>After conversion Data type of c “+typeof(c));


document.write(“<br>After conversion Data type of b “+typeof(b));




Understanding program :
In the above given program a is of number type , b is of string type, c is of Boolean type but when number variable (a) is assigned to b& c they both becomes of number type.
Value of c false
Value of b 23
Value of a 20
Data type of c boolean
Data type of b string
Data type of a number
After conversion Data type of c number
After conversion Data type of b number

Check Also

Recursive Functions In Java Script

A function which calls itself, is called a recursive function. When A function calls itself …