![]() Let newArray = array.slice(0, 3) // Return value is also an arrayįinally, I assign the sliced Array to the newArray variable. ![]() That’s why I call the second parameter “until”. array -> 1 // includedĪrray -> "hello world" // not included The slice( ) method doesn’t include the last given element. When I want to slice the first three elements, I must give the until parameter as 3. Since the first element of an array is always indexed at 0, I start slicing “from”0.
0 Comments
Leave a Reply. |