Home > Web Front-end > JS Tutorial > body text

Instance parsing Array and String methods

高洛峰
Release: 2016-12-29 09:08:57
Original
1522 people have browsed it

There is example code after the summary of each part. The yellow box method in the code does not change the original array. PS: All example results are obtained by running them one by one.

Array

——Normal 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(starting point[,end point]) splice(starting point,number[,multiple items])

Position: indexOf(item[,starting point]) lastIndexOf(item[,starting point])

Instance parsing Array and String methods

——Iteration method

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

Traversal: forEach()        

Mapping: map()                                                                                       ​

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

Merge: reduce() reduceRight()

String

Instance parsing Array and String methods——Common method

Character: charAt(position) charCodeAt(position) String. fromCharCode(multiple character encoding)

Space: trim()

Compare: localeCompare(string)

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

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

concat([multiple items]) slice(starting point[, end point])

Position: indexOf(item[, starting point]) lastIndexOf(item[, starting point])

——Matching method

Instance parsing Array and String methodsstr.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 It can bring some help to everyone's study or work, and I also hope to support the PHP Chinese website!

Instance parsing Array and String methods

For more examples of analysis of Array and String methods, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template