ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

parseInt: Javascript Function

Updated on October 26, 2007

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

    0 of 8192 characters used
    Post Comment

    • profile image

      sasha 7 years ago

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

    • profile image

      vijay 6 years ago

      thanks a ton.

    Click to Rate This Article