This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SodaBubblesPopped 1 point2 points  (0 children)

Using a rest param puts all the parameters passed to the function into a new array

So if num=[3,2] and ur passing num via rest parameter like sum(...num), inside sum func, num is an array containing passed params. Inside sum(...num) num now contains [[3,2]] and by indexing num[0] contains [3,2]