Summary of common methods in javascript

Source: Internet
Author: User
This article summarizes some common javascript methods for friends who are interested in the front-end. Concat () concatenates elements into an array

Join () converts all elements of the array into strings and joins them together.

Splice () insert, delete, and replace array elements

Push () adds the element to the end of the array

Pop () removes the last element of the array.

Shift () removes the first element of the array

Unshift () inserts an element in the array Header

Slice () returns part of the array

Every () test whether the asserted function is true for each array element

Some () tests whether at least one array element can make the asserted function true.

Foreach () specifies a function for each element of the array

Filter () returns an array element that satisfies the assertion function.

IndexOf () searches for matching elements in the array

LastIndexOf () reverse lookup in the array

Map () calculates the new array element from the array element.

Reduce () calculates a value from the array element from left to right.

Cerceright () reduces the array from right to left and calculates a value.

Sort () sorts array elements in the original array.

Reverse () reverses the order of array elements in the original array

ToLocaleString () converts an array to a localized string

ToString () converts an array to a string.

Split () Splits string into array elements

Var date = new Date () constructor

Date. now () returns the current time, in milliseconds after the epoch.

Date. parse () parses a string representation of the Date and time, and returns the internal millisecond representation of the Date.

Get [UTC] Date () returns the Date value in the month of the Date object, local or world time

Get [UTC] Day () returns the Date value in the week of the Date object, local or world time

Get [UTC] FullYear () returns the year of the date, in full 4-digit format, local or world time

Get [UTC] Hours () returns the hour value of the Date object, local or world time

Get [UTC] Milliseconds () returns the millisecond value of the Date object, and the local nose World Time

Get [UTC] Minutes () returns the minute value of the Date object, local or world time

Get [UTC] Month () returns the Month value of the Date object, local or world time

Get [UTC] Seconds () returns the second value of the Date object, local or world time

GetTime () returns the internal millisecond representation of the Date object. Note that this value is irrelevant to the time zone. Therefore, there is no separate getUTCTime method.

GetTimezoneOffset () returns the number of minutes between the local representation of the current date and the UTC representation. Note that the return value depends on whether the value is valid when the period of the specified date is used.

GetFullYear () returns the year value of a Date object.

GetMonth () returns the month value of a Date object.

GetDate () returns the Date value in the month of a Date object.

GetDay () returns the Date value of a Date object in a week.

GetHours () returns the hour value of a Date object.

GetMinutes () returns the minute value of a Date object.

GetSeconds () returns the millisecond value of a Date object.

GetTime () returns a Date object in milliseconds

GetMilliseconds () returns the millisecond value of a Date object.

ToJSON () serializes a Date object in JSON format, using toISOSTring ()

DecodeURI () decodes characters in a URI

DecodeURIComponent () decodes characters in a URI component

EncodeURI () escape characters in a URI

EncodeURIComponent () escapes characters in a URI component

The above is a summary of common methods in javascript. For more information, see other related articles in the first PHP community!

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.