Home > front end >  The usage slice parameters in the negative
The usage slice parameters in the negative

Time:03-12

 
Var a=[1, 2, 3, 4, 5].

A.s lice (0, 3);//return [1, 2, 3]

A.s lice (3);//return (4, 5)

A.s lice (1, 1);//return [4] 2

A.s lice (3, 2);//return [3]

The last sentence didn't understand, please explain

CodePudding user response:

- 3 is the third from bottom, - 2 is the last but one, which is equivalent to a.s lice (2, 3)

CodePudding user response:

From behind - 2 is the second from bottom

CodePudding user response:



Click on this link to slice parameter negative usage has a very detailed analysis
  • Related