Home  >  Article  >  Web Front-end  >  Summary of commonly used methods in javascript

Summary of commonly used methods in javascript

迷茫
迷茫Original
2017-03-26 15:07:221398browse

concat() connects elements to the array

join() converts all elements of the array into strings and connects them together

splice() inserts, deletes, and replaces array elements

push() adds elements 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 at the head of the array

slice() returns a part of the array

every() tests whether the assertion function is true for each array element

some() tests whether at least one array element can make the assertion function true

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

filter() returns an array that satisfies the assertion function Element

indexOf() finds matching elements in the array

lastIndexOf() searches in reverse in the array

map() calculates new elements from the elements of the array Array elements

reduce() calculates a value from the elements of the array from left to right

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

sort() sorts the array elements in the original array

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

toLocaleString() converts the array into a localized string

toString() converts the array into a string

split() splits the string into array elements

var date = new Date() constructor

Date .now() returns the current time, the number of milliseconds since the beginning of the epoch

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

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

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

get[UTC]FullYear() returns the year of the date, in complete 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, local or 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 seconds value of the Date object, local or world time

getTime() returns the internal millisecond representation of the Date object. Note that this value has nothing to do with the time zone. Therefore, there is no separate getUTCTime method

getTimezoneOffset() returns the current date between the local representation and the UTC representation. The difference in minutes. Note that the return value depends on whether daylight saving time on the specified date is valid

getFullYear() returns the year value of a Date object

getMonth() returns the month value of a Date object

getDate() returns the day value of the month of a Date object

getDay() returns the day value of the week of a Date object

getHours() returns the hour value of a Date object

getMinutes() returns the minutes value of a Date object

getSeconds() returns the millisecond value of a Date object

getTime() returns a Date object in millisecond form

getMilliseconds() returns the millisecond value of a Date object

toJSON() serializes a Date object to JSON and uses toISOTring()

decodeURI() to decode the characters in a URI

decodeURIComponent() decodes characters in a URI component

encodeURI() escapes characters in a URI

encodeURIComponent() escapes characters in a URI component

The above is the detailed content of Summary of commonly used methods in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn