Summary of common object functions in JS

Source: Internet
Author: User
Tags rounds

1. String object functions and attributes
Function:
CharAt (): returns the character at the specified position.
CharCodeAt (): returns the Unicode encoding of characters at the specified position.
Concat (): connection string.
IndexOf (): returns a string.
LastIndexOf (): Searches for strings from the back and forward.
Match (): finds matching of one or more regular expressions.
Replace (): replace the substring that matches the regular expression.
Search (): Searches for values that match the regular expression.
Slice (): extract the string segment and return the extracted part in the new string.
Split (): splits a string into a string array.
Substr (): extract a specified number of characters from the start index number.
Substring (): extract the characters between two specified index numbers in the string.
ToLowerCase (): converts a string to lowercase.
ToUpperCase (): converts a string to uppercase.
ToString (): returns a string.
Attribute:
Length: the length of the string.

2. Array object functions and attributes
Function:
Concat (): concatenate two or more arrays and return results.
Join (): put all elements of the array into a string. The elements are separated by the specified delimiter.
Pop (): deletes and returns the last element of the array.
Push (): add one or more elements to the end of the array and return a new length.
Reverse (): reverses the order of elements in the array.
Shift (): deletes and returns the first element of the array.
Slice (): returns the selected element from an existing array
Sort (): sorts the elements of an array.
Splice (): delete an element and add a new element to the array.
ToSource (): returns the source code of the object.
ToString (): converts an array to a string and returns the result.
ToLocaleString (): converts an array to a local array and returns the result.
Unshift (): add one or more elements to the beginning of the array and return a new length.
Attribute:
Length: Number of arrays

3. Time object functions and attributes
Function:
Date (): returns the Date and time of the current day.
GetDate (): returns a day (1 ~ 31 ).
GetDay (): returns a day of the week from the Date object (0 ~ 6 ).
GetMonth (): returns the month from the Date object (0 ~ 11 ).
GetFullYear (): returns the year from the Date object in four digits.
GetHours (): returns the hour of the Date object (0 ~ 23 ).
GetMinutes (): returns the minute of the Date object (0 ~ 59 ).
GetSeconds (): returns the number of seconds of the Date object (0 ~ 59 ).
GetMilliseconds (): returns the millisecond (0 ~) of the Date object ~ 999 ).
GetTime (): returns the number of milliseconds since January 1, January 1, 1970.
Parse (): returns the number of milliseconds from midnight, January 1, January 1, 1970 to the specified date (string.
SetDate (): set a day of the month in the Date object (1 ~ 31 ).
SetMonth (): set the month in the Date object (0 ~ 11 ).
SetFullYear (): set the year (four digits) in the Date object ).
SetYear (): Use the setFullYear () method instead.
SetHours (): set the hour in the Date object (0 ~ 23 ).
SetMinutes (): Set the minute in the Date object (0 ~ 59 ).
SetSeconds (): set the second in the Date object (0 ~ 59 ).
SetMilliseconds (): sets the millisecond in the Date object (0 ~ 999 ).
SetTime (): sets the Date object in milliseconds.
ToString (): converts a Date object to a string.

4. Mathematical object functions and attributes
Function:
Ceil (x): rounds up the logarithm.
Floor (x): returns the logarithm of a given number.
Max (x, y): returns the highest values in x and y.
Min (x, y): returns the lowest values in x and y.
Random (): returns 0 ~ A random number between 1.
Round (x): Rounds a number to the nearest integer.
Attribute:
PI: returns the circumference rate (approximately 3.14159 ).

5. JS global functions and attributes
Function:
DecodeURI (): Decode a URI.
DecodeURIComponent (): Decode an encoded URI component.
EncodeURI (): encodes a string into a URI.
EncodeURIComponent (): encodes a string into a URI component.
Escape (): encode a string.
Eval (): calculates the JavaScript string and runs it as script code.
IsNaN (): checks whether a value is a number.
Number (): converts an object value to a Number.
ParseFloat (): parses a string and returns a floating point number.
ParseInt (): parses a string and returns an integer.
String (): converts an object value to a String.
Unescape (): decodes a string encoded by escape.


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.