What's the difference between JavaScript arguments and the remaining parameters?
This article mainly explains the "what is the difference between JavaScript arguments and the remaining parameters". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between JavaScript arguments and the remaining parameters"?
The difference is that the 1:arguments object is an array-like object, but it's not a real array!
Keep in mind that JavaScript arguments objects are not real arrays. It is an object similar to an array and does not have any of the properties that an array has.
The remaining parameter is a real array on which you can use any method that the array has. For example, you can use the sort (), map (), forEach (), or pop () methods for one of the remaining parameters. But you cannot use these methods on arguments objects.
Difference 2: you cannot use the arguments object in the arrow function
The arguments object is not available in the arrow function, and the remaining parameters are available in all functions, including the arrow function.
Difference 3: give priority to the remaining parameters
The remaining parameters are preferred over arguments objects, especially when writing ES6-compatible code.
Now that we have seen how the residue operator works, let's discuss the expansion operator and see the difference between it and the residue operator.
What is the unfold operator and how does it work in JavaScript?
The expansion operator (...) expands an iterable object into a single element.
The expansion operator can be applied to array literals, function calls, and initialized property objects, which expand the values of iterable objects into separate elements one by one. In fact, it is the opposite of the remaining operator.
Thank you for reading, the above is the content of "what's the difference between JavaScript arguments and the remaining parameters". After the study of this article, I believe you have a deeper understanding of the difference between JavaScript arguments and the remaining parameters, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!