JavaScript Basics-Built-in classes

Source: Internet
Author: User

Date class:

(1) Construction method

var ndate=new Date ()

var ndate=new date (value)//value is the time difference from date to January 1, 1970

The Var ndate=new date (y,m,d,h,m,s,ms)//y can be a two-digit representation of 19, which can be 4 bits for a specific year, M is zero-based, and D represents a date of 1-31. H is (0-23).

(2) The method

static method: Date.now () DATE.UTC () Date.parse ()

General method: Getxx () gets a value for a property.

GetDate ()//returns the date of the specified Date object based on local time, which is the number of the month

GetDay ()//Returns a few days of the week based on the number of weeks that the specified Date object is returned locally.

GetMonth ()

JSON class

Static methods

(1) json.stringify (value.[ Replace],[space])//value is a complex data type that will be serialized as a JSON string.

This method is to convert a complex data type to a JSON string, which is actually called the Tojson () method in the JS type, which cannot be converted if the type does not define the method. The types that have been defined are:

The Boolean String Date number is deleted for Object and the Array is replaced with null. Some of these characters are escaped. "\ b F n T and so on

Replace: Is the role of data filtering and data conversion, replacing values in value with replace, or filtering out some properties through replace.

Space: is the JSON format control plus white space character.

(2) Json.parse (Text[,revicer])

is to convert the JSON format data to JavaScript data in reverse order. The final return is an object or an array.

Where text is data in JSON format, Revicer is the result of filtering and conversion. The function is called on each object member from the back to the previous order.

If the function returns a value, the value of the member is replaced.

If it returns itself, it will not change

If the return is undefined or null, then the object member is deleted.

JavaScript Basics-Built-in classes

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.