Example of method for parsing Array and String in js

Source: Internet
Author: User

After each part is summarized, there is an instance code. The yellow box method in the code does not change the original array. PS: all instance results are obtained one by one.

Array

-- Common method

Stack: Pop () push (multiple items)

Queue: Shift () unshift (multiple items)

Sort: Sort ([function]) reverse ()

Conversion: ToString () toLocateString () join ([separator])

Operation: Concat ([multiple items]) slice (start point [, end point]) splice (start point, number of items [, multiple items])

Location: IndexOf (item [, start point]) lastIndexOf (item [, start point])

-- Iteration method

Parameters:( Function (value, position, array itself) [, scope object])

Traversal: ForEach ()

Ing: Map ()

Filter: Filter ()

Detection: Every () some ()

Parameters:( Function (previous value, current value, position, array itself) [, initial value])

Merge: Reduce () reduceRight ()

String

-- Common method

Character: CharAt (location) charCodeAt (location) String. fromCharCode (multiple character encoding)

Space: Trim ()

Comparison: LocaleCompare (string)

Conversion: ToUpperCase () toLowerCase () toLocaleUpperCase () toLocaleLowerCase () split ([connector])

Operation: Substring (start point [, end point]) substr (start point [, number]) replace (RegExp/string, string/function)

Concat ([multiple items]) slice (start point [, end point])

Location: IndexOf (item [, start point]) lastIndexOf (item [, start point])

-- Matching method

Str. match (reg) reg.exe c (str)

Str. search (reg) reg. test (str)

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.