Personal summary of some of the properties and usage of string, Function, Array _ Basics

Source: Internet
Author: User
Copy Code code as follows:


/* Array */
Array.reverse ()///array reverse sort, into a new array.
Array.Sort ()///Sort the array into a new array by character.
S=array.push ("str1", "str2")//Add array from back, s to add record
S=array.pop ()//delete array from the back, s for deleted records
S=array.shift ()//remove array from front, s for deleted records
S=array.unshift ("str1", "str2")//Add array from front, s to add record
S=array.splice (3,2, "AA", "BB")//starts with the third of the array, deletes two arrays backwards, and adds a new array at that location. s to add a record
S=array.slice (2,4)//starts from the second after the array, takes the fourth, and the array itself does not change.
S=ar1.concat (AR2)//Add the array Ar2 to the array Ar1, generating the new array S.
S=array.join ("#")//The array element is concatenated with a #, forming a string and returning to S.

/* Function/*
Sample:function Test (ARG1,ARG2)
Use:test ("ddd", "SSS", "FFF")
Test.arity://function set number of parameters (return value).
Test.length://function set number of parameters (return value).
Test.caller://Call function for Test () (return function, IE support).
Test.apply (obj, [Arg1, arg2])//makes the specified object (obj) have properties and methods of test.
Test.call (obj, arg1, arg2)//makes the specified object (obj) have properties and methods of test.
Arguments://Actual number of arguments passed in (array returned).
Arguments.callee://currently executing function (return function).
(new Test). Constructor://View the construction (return function) of the new instance (test ()).

/* String */
Str.slice (3,-5)//starts at the end of the third string and takes the first 5 (bottom fifth). Parameter two needs to be greater than parameter one, or negative.
Str.substring (3,6)//starts after the third string and takes the 6th one.
STR.SUBSTR (3,6)//starts after the third string and takes 6 characters backwards.
Str.charcodeat (4)//Returns the 10 encoding of the 5th string.
Str.charat (4)//returns a 5th string.
Str.tolowercase ()//all converted to lowercase characters.
Str.touppercase ()//all converted to uppercase characters.
Str.split (",")//Use "," splits the string and returns an array.
Str.search ("AAA")//Find the position of AAA in the string, commonly used with regular expressions.
Str.indexof ("AAA")//Find the position of AAA in the string.
Str.lastindexof ("AAA")//begins by looking for the position where "AAA" appears in the string.
Str.match ("AAA")//"AAA" removed from STR, returns null or array, and is used in conjunction with regular expressions.
Str.replace ("AAA", "BBB")//Replace the first "triple" with "BBB" and use it in conjunction with regular expressions.
String.fromCharCode (39080)//Returns the character generated by a 10-encoded encoding.
Str1=str2.concat (STR3)//Add STR3 to str2 to generate a new string str1.



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.