A brief talk on JS common built-in methods and object _javascript skills

Source: Internet
Author: User

JS built-in functions do not belong to any object, in the JS statement anywhere can directly use these functions. The built-in functions commonly used in JS are as follows:

1, eval (str) receives an expression in the form of a string and attempts to find the value of the expression. An expression that is a parameter can take any valid operator and constant. If the parameter contains the JS command, these commands can also be executed as if they were part of a JS program.

2, parseint (Str,n) attempted to extract an integer from a string. An n-integer implementation can be appended to return an n-ary integer. If there are characters in the string other than numbers, symbols, decimal points, and exponential symbols, the conversion is stopped and the results are returned. If the first character cannot be converted, the function returns a Nan value.

3, parsefloat (str) attempted to extract a floating-point value from a string. If there are characters in the string other than numbers, symbols, decimal points, and exponential symbols, the conversion is stopped and the results are returned. If the first character cannot be converted, the function returns a Nan value.

4, isNaN () is used to determine whether a Nan value type, if the function returns True.

5, Isfinite (number) can determine whether the parameter number is an infinite. Returns True if the function returns FALSE.

6, Escape () accept a string, this string may contain spaces, semicolons and other characters. function to convert a string into a cookie's internal representation. The function return value is this internal expression.

7. Unescape () accepts a cookie and converts its internal expression into a normal string form. JS functions can be divided into general functions, array functions, date functions, mathematical Functions, String functions, and so on five categories.

One, 9 general functions

(1) Alert function: Displays a warning dialog box, including an OK button.

(2) Confirm function: Displays a confirmation dialog box, including OK, Cancel button.

(3) Escape function: Converts a character to a Unicode code.

(4) Eval function: Evaluates the result of an expression.

(5) isNaN function: Test is (true) No (false) is not a number.

(6) parsefloat function: Converts a string into a character point number form.

(7) parseint function: Converts a string into an integer number form (you can specify a few).

(8) Prompt function: Displays an input dialog box that prompts for user input.

(9) Unescape function: Decodes characters encoded by the escape function.

Two, array objects 4 arrays function

(1) Join function: Set separator connection array element is a string.

(2) Langth function: Returns the length of an array.

(3) Reverse function: Reverses the order of the array elements.

(4) Sort function: Reorder the elements of an array.

20 Date function of data object

(1) getdate function: Returns the "Day" section of the date, and the value is 1~31.

(2) Getday function: Returns the week, the value is 0~6,0 represents Sunday.

(3) gethours function: Returns the "Hour" section of the date, and the value is 0~23.

(4) Getminutes function: Returns the "Minutes" section of the date, and the value is 0~59.

(5) GetMonth function: Returns the "month" section of the date, and the value is 0~11.

(6) Getseconds function: Returns the "Seconds" section of the date, and the value is 0~59.

(7) GetTime function: Returns the system time.

(8) getTimezoneOffset function: Returns the time difference for this region (local times and GMT Greenwich Mean time interval), in minutes.

(9) GetYear function: Returns the "Year" section of the date. The return value is based on a 1900-year base, such as 1999 99.

(a) Parse function: Returns the number of milliseconds (local time) from January 1, 1970 zero.

(one) setdate function: Set the date of the "Day" section, the value is 0~31.

sethours function: The "hour" section of the set date, and the value is 0~23.

(setminutes function: The "Minutes" section of the set date, and the value is 0~59.)

setmonth function: The "month" section of the set date, and the value is 0~11. Of these, 0 said January, ..., 11 means December.

setseconds function: The "Seconds" section of the set date, and the value is 0~59.

(settime) Function: Set time. The time value is the number of milliseconds from the whole of January 1, 1970 zero.

(setyear) function: The "Year" section of the set date.

(togmtstring) Function: convert date to string, GMT Greenwich Standard Time.

setlocalestring function: The conversion date becomes a string, local time.

(20) UTC function: Returns the number of milliseconds (GMT) from the whole of the January 1, 1970 zero.

Iv. properties and functions of the Math object

The main properties are

MATH.E (e natural logarithm)

MATH.LN2 (natural logarithm of 2)

MATH.LN10 (natural logarithm of 10)

MATH.LOG2E (logarithm of E, base 2)

MATH.LOG10E (logarithm of E, base 10)

Math.PI (pi Pi)

Math.sqrt1_2 (square root value of 1/2)

Math.sqrt2 (square root value of 2).

There are 18 functions:

(1) ABS function: Math.Abs (in the same below), returns the absolute value of a number.

(2) ACOs function: Returns the inverse cosine of a number, resulting in 0~π radians (radians).

(3) ASIN function: Returns the inverse string value of a number, the result is-Π/2~Π/2 radians.

(4) Atan function: Returns the tangent value of a number, the result is-Π/2~Π/2 radians.

(5) ATAN2 function: Returns the polar coordinate angle value of a coordinate.

(6) Ceil function: Returns the smallest integer value (greater than or equal to) of a number.

(7) Cos function: Returns the cosine of a number, the result is -1~1.

(8) Exp function: Returns the exponentiation value of E (natural logarithm).

(9) Floor function: Returns the maximum integer value of a number (less than or equal to).

Log function: A natural logarithmic function that returns the natural logarithm (e) value of a number.

(one) Max function: Returns the maximum value of two digits.

Min function: Returns the minimum value of two digits.

(POW) Function: Returns the value of a number's exponentiation.

(random) Function: Returns a random number of 0~1.

(round) Function: Returns the rounded value of a number, which is an integer.

Sin function: Returns the sine of a number, and the result is -1~1.

(sqrt) function: Returns the square root value of a number.

Tan function: Returns the tangent value of a number.

Five, String objects 20 strings function

(1) Anchor function: Create a link point (anchor) for use as a hyperlink.

(2) Big function: Add the font to a number, the same as the <BIG>...</BIG> label results.

(3) BLINK function: Make string flicker, same as <BLINK>...</BLINK> label result.

(4) Bold function: Make the font bold, the same as the <B>...</B> label results.

(5) Charat function: Returns a character specified in the string.

(6) Fixed function: Set the font to a fixed-width font, the same as the <TT>...</TT> label results.

(7) FontColor function: Set the font color, the same as the <FONTCOLOR=color> label results.

(8) FontSize function: Set the font size, the same as the <FONTSIZE=n> label results.

(9) IndexOf function: Returns the first found subscript index in the string, starting from the left.

(Ten) italics function: Make font italic, same as <I>...</I> label result.

(one) LastIndexOf function: Returns the first found subscript index in the string, starting from the right.

() Length function: Returns the length of a string. (without parentheses)

Link function: Produces a hyperlink, which is equivalent to the URL of the set <AHREF=...>.

(SMALL) function: Reduce the font by one number, the same as the <SMALL>...</SMALL> label results.

STRIKE function: Add a horizontal line to the middle of the text, the same as the <STRIKE>...</STRIKE> label result.

Sub function: Displays a string as the subscript (subscript).

(substring) Function: Returns a number of characters specified in a string.

(a) SUP function: Display string as superscript (superscript).

(tolowercase) Function: Converts a string to lowercase.

toUpperCase function: Converts a string to uppercase.

The above is small series for everyone to talk about JS commonly used built-in methods and objects of the entire content, hope to help everyone, a lot of support cloud Habitat Community ~

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.