Page 347 - Webapplication11_C11_Flipbook
P. 347

<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>
                 Output of the above code is as follows:















                                                                                                  JavaScript Part 1  345
   342   343   344   345   346   347   348   349   350   351   352