Some time ago I saw somewhere the thing that Array.slice(0) is faster than Array.slice(). Unfortunately now I can't find that source. So is that possible ? There is any difference between Array.slice(0) and Array.slice() ?
3 Answers
There's no difference, because begin is assigned to 0 by default if you don't provide any parameter to Array.slice() method.
begin
OptionalZero-based index at which to begin extraction. A negative index can be used, indicating an offset from the end of the sequence.
If begin is undefined, slice begins from index 0.
For more info: link
Comments
slice is something like this:
function slice(start) {
if( /* start is not valid */ ) {
start = 0;
}
// ...
}
The only diffirence is wether the line start = 0 is evaluated or not! So the only change in evaluation time will be that of the assignment which is not very costly comparing it to the rest of the code!
Comments
If you won't pass any argument to the Array.slice() function, the default state will be set to 0.
If begin is undefined, slice begins from index 0.
sliceassumes it's0.