The Math object for JavaScript Foundation 14--js

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTML>3     <Head>4         <MetaCharSet= "UTF-8">5         <title>JS's Math Object</title>6         <Scripttype= "Text/javascript">7             //the Math object is a static method that you can use without instantiating an object.8             varNum= 10.5;9 document.write ("Initial value:" +num);Ten             //ceil () method, rounding a number One document.write ("<br/> Rounding up the Ceil () method:" +Math.ceil (num)); A             //Floor () method, rounding down a number - document.write ("<br/> Rounds down the Floor () method:" +Math.floor (num)); -             //round () method, rounding a number the document.write ("<br/> Rounding Round () method:" +Math.Round (num)); -             //Random (), gets the stochastic number (0.0-1.0 pseudo-random number). Get a random number of 0-9 - document.write ("<br/> Random number ():" +Math.floor (Math.random ()* Ten)); -             functionGetrandom () { + document.getElementById ('Mark'). InnerHTML= "Random Number:" +Math.floor (Math.random ()* Ten); - SetTimeout ('getrandom ()',  $); +             } A         </Script> at     </Head> -     <Bodyonload= "Getrandom ()"> -         <PID= "Mark">Random number</P> -     </Body> - </HTML>

The Math object for JavaScript Foundation 14--js

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.