Javascript Array.slice () vs Array.slice (0)
There is no difference as it is begin
assigned 0
by default if you do not provide any parameter to the method Array.slice()
.
to begin
Optional
Zero-based index to start extraction. you can use a negative index by specifying an offset from the end of the sequence.
If the start is undefined, the slice starts at index 0.
For more information: link
source to share
slice
looks something like this:
function slice(start) {
if( /* start is not valid */ ) {
start = 0;
}
// ...
}
The only difference is whether the line start = 0
is being evaluated or not! So the only change to the evaluation time would be that the assignment, which is not very expensive, compares it to the rest of the code!
source to share