About the split of js, why the first and last items of the returned array are two empty strings.

clipboard.png

do not understand what this means, ask the boss to answer

Apr.23,2022

The

split method splits the incoming string or regular expression as a delimiter.

the meaning here is not difficult to understand

  

/ [^\,] + / refers to the division of multiple characters other than and . The corresponding delimiters in color3 are red , blue , green , yellow , , . The one referred to in the
text begins with red and ends with yellow , that is, at the beginning of the whole string "red,.." red divides the preceding and subsequent characters, and happens to be followed by , , but red is preceded by no actual characters, so replace it with empty characters. Similarly yellow , there is a , before it, and there is no actual character after it, so an empty string

cannot be added.
Menu