Tuesday, October 21, 2014

Datatype Conversion

Types Conversion Function:

1)isNan():Check to see if what is passed is not a number,return a boolean output

<script type="text/javascript">
document.write("111 IS:"+isNaN(111)+"<br>");
document.write("-111.45 IS:"+isNaN(-111.45)+"<br>");
document.write("Hello IS:"+isNaN("Hello")+"<br>");

2)eval():It convert String to Integer or Float
It Can Also Evalute the Expression include with a string.

<script type="text/javascript">
var Ans=eval("256/7*8");
document.write("The Correct Answer IS:"+Ans);

3)parseInt():Convert The String to Integer Value.
Return The First Integer Which is Contain in String.

<script type="text/javascript">
document.write("111.111 Value:"+parseInt(111.111)+"<br>");
document.write("123Good456 Value:"+ parseInt (123Good456)+"<br>");
document.write("Hello Value:"+ parseInt ("Hello")+"<br>");

4)parseFloat():Convert The String to Floating Point Number.
Return The First Floating Point Number  Which is Contain in String.

<script type="text/javascript">
document.write("111.111 Value:"+parseFloat(111.111)+"<br>");
document.write("123.45Good1 Value:"+ parseFloat(123.45Good1)+"<br>");
document.write("Hello Value:"+ parseFloat ("Hello")+"<br>");


Unknown said...

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from

Alwin Co Daan said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai