How to get a slice from “arguments”

后端 未结 7 1895
天命终不由人
天命终不由人 2020-12-01 09:10

All you know that arguments is a special object that holds all the arguments passed to the function.

And as long as it is not an array - you cannot use

7条回答
  •  抹茶落季
    2020-12-01 09:38

    From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments:

    You should not slice on arguments because it prevents optimizations in JavaScript engines (V8 for example). Instead, try constructing a new array by iterating through the arguments object.

    So Paul Rosiana's answer above is correct

提交回复
热议问题