Example parsing array and string methods _javascript tips

Source: Internet
Author: User
Tags string methods

After each section summarizes has the instance code, the Code yellow box method does not change the original array. PS: All instances of the results are run.

Array

--Common method

Stacks: pop () push (multiple items)

queues:shift () Unshift (multiple items)

sorting:sort ([function]) reverse ()

Convert:toString () tolocatestring () join ([separator])

Action:concat ([multiple items]) slice (starting point [, end Point]) splice (starting point, Number [, multiple items])

Location:indexOf (Entry [, start]) LastIndexOf (entry [, starting point])

--Iterative method

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

Traversal:ForEach ()

Mapping: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 (position) charcodeat (position) String. fromCharCode (multiple character encodings)

Space: trim ()

comparison: localecompare (String)

Convert: touppercase () toLowerCase () toLocaleUpperCase () toLocaleLowerCase () split ([connector])

Action: substring (beginning [, end]) substr (start [, number]) replace (regexp/string, string/function)

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

Location: indexOf (Entry [, start]) LastIndexOf (entry [, starting point])

--matching method

Str.match (REG) reg.exec (str)

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

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!

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.