JS String method

Source: Internet
Author: User

String method
Returns the character according to the subscript:
Str.charat ()//pass in a subscript return character
Str.charcodeat ();//pass in a subscript to get the encoding
String.formcharcode ();//Accept the code, encode the turn character
Incoming characters return subscript:
Str.indexof ();//Incoming character returns subscript, multiple characters can be passed in
If the return-1 is the description not found
Str.lastindexof ();
Start from right to left
Intercept and return a string:
Str.substring ();//pass in two subscript, return the intercepted character, if do not pass anything then direct return, if enter and leave negative is directly treated as zero, can handle subscript size to correct adjustment
Str.slice ();//can receive negative numbers, can be backwards from behind the number of forward
Note: Simply return the intercepted content without changing the original string;
Convert to Case:
Str.touppercase ();//Large
Str.tolowercase ();//Small

String segmentation Array
Str.split ("."); Incoming delimiters
Returns an array of string characters in the word ""
If a character is passed in, it is divided into two two array elements directly from this character.
You can also pass in the length of an array more

JS String method

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.