Attributes and usage of string, function, and array

Source: Internet
Author: User
Tags sorts
/* Array */
Array. Reverse () // sorts the array in reverse order and changes it to a new array.
Array. Sort () // sorts the array by characters and changes it to a new array.
S = array. Push ("str1", "str2") // Add an array from the back. S is the Add record.
S = array. Pop () // Delete the array from the back, and s is the deleted record
S = array. Shift () // Delete the array from the front, and s is the deleted record
S = array. unshift ("str1", "str2") // Add an array from the front. S is the Add record.
S = array. splice (, "AA", "BB") // Delete two arrays from behind the third array, and add a new array at this position. S: Add record
S = array. Slice (2, 4) // starts from the second end of the array and obtains the fourth value. The array itself has not changed.
S = ar1.concat (AR2) // Add array AR2 to array AR1 to generate a new array S.
S = array. Join ("#") // concatenate array elements with # To form a string and return it to S.

/* Function */
Sample: function test (arg1, arg2)
Use: Test ("DDD", "Sss", "fff ")
// Test. Arity: // number of parameters set by the function (return value ).
Test. Length: // number of parameters set by the function (return value ).
Test. Caller: // call the test () function (returned function, supported by IE ).
Test. Apply (OBJ, [arg1, arg2]) // make the specified object (OBJ) have the attributes and methods of test.
Test. Call (OBJ, arg1, arg2) // make the specified object (OBJ) have the attributes and methods of test.
Arguments: // The number of actually passed parameters (returned array ).
Arguments. callee: // The currently executed function (return function ).
(New test). constructor: // view the structure (return function) of the new instance (test ).

/* String */
Str. Slice (3,-5) // start from the end of the third string and obtain the-5 (the fifth to the last. Parameter 2 must be greater than parameter 1 or be negative ).
Str. substring (6th) // starts from the end of the third string and obtains values.
Str. substr () // starts after the third string and takes 6 Characters backward.
Str. charcodeat (4) // returns the 10-digit encoding of the 5th strings.
Str. charat (4) // returns 5th strings.
Str. tolowercase () // convert all to lowercase characters.
Str. touppercase () // All are converted to uppercase/lowercase characters.
Str. Split (",") // use "," to split the string and return an array.
Str. Search ("AAA") // finds the position of AAA in the string, which is generally used together with a regular expression.
Str. indexof ("AAA") // locate the position of AAA in the string.
Str. lastindexof ("AAA") // search for the position where "AAA" appears in the string.
Str. Match ("AAA") // extracts "AAA" from STR, returns NULL or an array, which is generally used together with a regular expression.
Str. Replace ("AAA", "BBB") // Replace the first "AAA" with "BBB", which is generally used together with a regular expression.
String. fromcharcode (39080) // returns a 10-digit encoded character.
Str1 = str2.concat (str3) // Add str3 to str2 to generate a new string str1.

(From 51js rimifon (unknown ))

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.