JavaScript base -11 JavaScript wrapper class object (Math, Date, number, Boolean)

Source: Internet
Author: User

One, JavaScript Math object


Math Object Overview

-The Math object is a global object provided by ECMAScript, which mainly encapsulates some commonly used mathematical functions and constants

-The Math object does not have a constructor, cannot create an instance of it (instance), and when its properties and methods are called, use the Math object name directly

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/2B/wKioL1b44DDzGgzVAABbavkSk_M356.png "title=" Web.png "alt=" Wkiol1b44ddzggzvaabbavksk_m356.png "/>


Properties of the Math object

-The Math object has the following member properties

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/2B/wKioL1b44RvReowWAACzKKlHl-A181.png "title=" Web.png "alt=" Wkiol1b44rvreowwaaczkklhl-a181.png "/>


Methods of the Math object

-The Math object has the following member methods

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/2F/wKiom1b44OHSeZQHAACoa5kNViU943.png "title=" Web.png "alt=" Wkiom1b44ohsezqhaacoa5knviu943.png "/>


Trigonometric function

-The Math object provides a common trigonometric function calculation method

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/2F/wKiom1b44Q2QijntAACFcgMO-kg150.png "title=" Web.png "alt=" Wkiom1b44q2qijntaacfcgmo-kg150.png "/>


Random number

-The Math object provides a function to generate a random number

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7E/2F/wKiom1b44T6TPshsAACEdQUJsO8898.png "title=" Web.png "alt=" Wkiom1b44t6tpshsaacedqujso8898.png "/>


Second, JavaScript Date object


Create a Date object

-Date objects are used to store and calculate times and time

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/2B/wKioL1b44pDD8Dm2AADS0hFIsw8392.png "title=" Web.png "alt=" Wkiol1b44pdd8dm2aads0hfisw8392.png "/>


Get time Information

-You can use the following methods to get time information from a Date object

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7E/2B/wKioL1b44tyDoe8oAAEIIY3dAac699.png "title=" Web.png "alt=" Wkiol1b44tydoe8oaaeiiy3daac699.png "/>


Modify Time Information

-You can modify the time information in a Date object using the following methods

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7E/2B/wKioL1b44yHCKPo7AADWRwdXEUs689.png "title=" Web.png "alt=" Wkiol1b44yhckpo7aadwrwdxeus689.png "/>


Time format Conversion

-The Date object can be formatted using the following method

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/2B/wKioL1b4413xLSjXAADmwOQ7Me4869.png "title=" Web.png "alt=" Wkiol1b4413xlsjxaadmwoq7me4869.png "/>


Second, JavaScript Number object


Create Number Object

-The Number object represents numeric data and numeric constants, which are used primarily for outputting numbers in a specified format

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/2F/wKiom1b44w3jWtaKAADB4J5Eyv4606.png "title=" Web.png "alt=" Wkiom1b44w3jwtakaadb4j5eyv4606.png "/>


Number object property

-The Number object has the following static constant property

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7E/2F/wKiom1b448bA3DQ_AABZuvml8PU740.png "title=" Web.png "alt=" Wkiom1b448ba3dq_aabzuvml8pu740.png "/>


Number Object method

-You can use the following methods to get time information from a Date object

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/2F/wKiom1b44_WRpyrfAACEaLdoP_M081.png "title=" Web.png "alt=" Wkiom1b44_wrpyrfaacealdop_m081.png "/>


Third, JavaScript Boolean object


Create a Boolean object

-A Boolean object that represents a Boolean object (True and False)

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7E/2C/wKioL1b45V-ipo4UAACNz5PERHs724.png "title=" Web.png "alt=" Wkiol1b45v-ipo4uaacnz5perhs724.png "/>-Boolean object represents a Boolean object (True or False)

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7E/2F/wKiom1b45PaR830jAADHqAe3Q2U387.png "title=" Web.png "alt=" Wkiom1b45par830jaadhqae3q2u387.png "/>

Summary: This chapter covers JavaScript wrapper class objects (Math, Date, number, Boolean)


This article from the "Technical Exchange" blog, declined reprint!

JavaScript base -11 JavaScript wrapper class object (Math, Date, number, Boolean)

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.