Application of JS built-in object

Source: Internet
Author: User
Tags pow square root

Boolean, number, Object
Function object
Another way to do this:
var add=new Function ("x", "Y", "Return (X+y)");
Arguments property: Real parameter Group
Math Object
Provide scientific functions and constants
Property:
E PI, etc.
Method:
ABS for absolute ceil (rounding up) floor (rounded down) round (round) POW (A, B) (returns a of the second party) random sqrt (square root)
String Object
Property:
Length
Method:
CharAt concat indexOf lastIndexOf replace (reexp,replacetext) search (rgexp) split substr (start[,length ]) substring (start,end) tolowercase touppercase valueOf ()
Match (RGEXP) (uses the regular expression pattern to find the string and returns the result of the lookup as an array)
RegExp Object
RegExp objects cannot be created directly, but can always be used. The initial value of each property before a successful regular expression lookup is:
Index-1
LastIndex-1
Lastmatch ""
Property:
Input: The last string found
Index: Find the first matching starting subscript
LastIndex: The next match that satisfies the condition begins, and returns 1 if there is no next occurrence
Lastmatch: Returns the last matched string
Leftcontext: A string that returns the beginning of the string to the end of the string before it matches the position
Rightcontext: Returns the first match ending position of the string to the end of the string character

RegExp Regular Expression Object
Structure:
Re=/pattern/[flags]
Re=new RegExp ("pattern", ["flags"])
Parameters:
Re: regular expression variable name
Pattern: The regular expression pattern used
Flag: Use Flag
G: Full text Find all occurrences of pattern
I: Ignore case
M: Multi-line Lookup
Method:
Rgexp.complie (Pattern,[flags]); Compiles a regular expression into an internal format, which executes faster and returns a regular expression object
Rgexp.exec (str): Runs a lookup in a string with a regular expression and returns an array containing the lookup object

var F1=NewFunction ("A", "B", "Return (A+B)")); //Alert (F1 (2,3)); //alert ("PI:" +math.pi); //alert ("E:" +MATH.E); //Alert (Math.Abs (-1)); //Alert (Math.ceil (1.23)); //Alert (Math.floor (1.67)); //Alert (Math.Round (1.45)); //Alert (MATH.SQRT (4)); //alert (Math.pow (2,3));var s=NewString ("Gjhdgsjkdgsjgfs"); //alert (s.length); //Alert (S.charat (3)); //Alert (S.concat ("HLKHK")); //There's been a mistake.var re=/"JH"/G; Re=NewRegExp ("JH", "G"); //alert (S.replace (re,h));alert (re.index);</script>
View Code






Application of JS built-in object

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.