Page 304 - Web Applications (803) Class 11
P. 304

JavaScript provides a number of built-in functions, which are as follows:
              Ð ÐisNaN( ):  It return true, if the object is NOT a number, it returns false, if the object is a number.
                 For example:

                 <!DOCTYPE html>
                 <HTML>
                 <HEAD>
                     <TITLE> NaNfunction </TITLE>
                 </HEAD>
                 <BODY>

                     <H1> Using NaN </H1>
                 <SCRIPT>
                 document.write("<br>"+isNaN(5))
                 document.write("<br>"+isNaN("7"))
                 document.write("<br>"+isNaN("six"))
                 </SCRIPT>
                 </BODY>
                 </HTML>
              Output of the above code is as follows:















              Ð ÐparseInt(): If the string begins with an integer, the function reads through the string until it finds the end of the
                 integer, cuts off the remainder of the string and returns the result. If the string does not begin with an integer, the
                 function returns NaN (Not a Number).

                 For example:
                 <!DOCTYPE html>
                 <HTML>
                 <HEAD>
                     <TITLE> ParseInt function </TITLE>
                 </HEAD>
                 <BODY>
                     <H1> Using ParseInt </H1>
                 <SCRIPT>
                       var stringDate = "6786asdf";
                     var intDate = parseInt(stringDate, 10);
                     document.write(intDate)
                  </SCRIPT>
                 </BODY>
                 </HTML>
                302     Touchpad Web Applications-XI
   299   300   301   302   303   304   305   306   307   308   309