Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Array.slice() vs Array.slice(0)

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() ?

like image 553
icharts Avatar asked Dec 19 '22 08:12

icharts


1 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 Optional

Zero-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

like image 79
Alexander Romanov Avatar answered Dec 28 '22 23:12

Alexander Romanov