parseInt: Javascript Function

parseInt(5) equals 5

parseInt(null) equals NaN

parseInt(3.1) equals 3

parseInt(0) equals 0

parseInt('ABC') equals NaN

parseInt(-10) equals -10

The following program demonstrates parsing:

<HTML>

<HEAD>

<TITLE>parseInt </TITLE>

<SCRIPT>

function displayparseInt(n) {

document.write('parseInt of '+n+' equals '+parseInt(n)+'<BR>');

}

displayparseInt(5);

displayparseInt(null);

displayparseInt(3.1);

displayparseInt(0);

displayparseInt('ABC');

displayparseInt(-10);

</SCRIPT>

</HEAD>

</HTML>

Comments 2 comments

sasha 7 years ago

hi i would like an example on how to use parseint in creating web pages for odd and even numbers


vijay 6 years ago

thanks a ton.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working