1. Summary of array method
Will change the original array
push, unshift methods, return length. If you add value, return length, and the other return the element
pop, shift returns this element
reverse returns this element
splice(start, deleteCount, addItem...), delete and add from the original array, return the deleted array
Will not change the original array, return the new array
concat,join,slice(start,end)
Remember these 3 are returning new arrays, the others will change the original array
2. Summary of Sting's method
If no changes to the original value are made, a new String or other value is returned.
1. It should be remembered that the results of string.match(regexp does not contain g) and regexp.exec(string) are the same.
If the capturing packet is grouped, the subscript is a substring matched by 0, and the subscript is a packet of 1 captured text
If marked with g, string will generate an array containing all matching (except for capturing groups); regular exec can be judged step by step down to determine whether it is null.
All lastIndex of reg are available.
2. string.slice(start,end), the end parameter is equal to the position +1 of the last character you want to take. 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 method
3. Regularity can be used for replacement or grouping.
string.split(separator, limit), limit can limit the number of segments to be split, and whether there is any g or not
string.replace(searcdhValue, replaceValue), the sequencedhValue regularity will replace all matches if g, and if not, just replace the first match.
If it is a string, the value is replaced where it first appears
Learning is a gradual process. Only by constantly summarizing and constantly learning can there be qualitative breakthroughs. Recently, I have been summarizing some things about JavaScript. I hope that I and everyone can get to the next level.