Home > Article > Web Front-end > Instance parsing Array and String methods
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])
——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——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 methodstr.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! For more examples of analysis of Array and String methods, please pay attention to the PHP Chinese website!