Notes for Array and string Methods

Source: Internet
Author: User
Tags string methods

Summary of array Methods

 

Will change the original array

The push and unshift Methods return the length. If the value is added, the length is returned. If the value is increased, other elements are returned.

Pop, shift returns this element

Reverse returns this element

Splice (START, deletecount, additem...), delete and add from the original array, return the deleted Array

Returns a new array without changing the original array.

Concat, join, slice (START, end)

Remember that the three are new arrays, and the others will change the original array.

 

Summary of the sting Method

If the original value is not changed, a new string or other values are returned.

1. When the response is string.match(regexpwithout gnames and regexp.exe C (string), the result is the same.

If the g id is used, all matching arrays (except the capture group) are generated)

2. String. slice (START, end), the end parameter is equal to the position of the last character you want To take + 1. If you want to get the nth character starting from position P, use string. slice (p, p + n)

String. substring is the same as array. slice.

3. Regular Expressions can be used for replacement or grouping.

String. Split (separator, limit), limit can limit the number of segments to be split, and the regular expression has the same g

String. Replace (searcdhvalue, replacevalue), searcdhvalue if the regular expression contains g, all the matches will be replaced. If not, only the first match will be replaced.

If it is a string, the value is replaced in the first place where it appears

 

Take two months to sort out the JS knowledge.

 

Notes for Array and string Methods

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.